#!/usr/bin/env osh : : osh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: strlen.osh 410 2008-05-15 05:01:41Z jneitzel $ " : : " The author of this file, J.A. Neitzel , " : " hereby grants it to the public domain. " : : : " Use expr(1) to print the length of the specified string. " : : " usage: strlen string " : : " Check for correct usage. " : >>$0'' <'' ; : >>$1'' <'' killer $0'' strlen if $n != 1 if { exit } pusage $0 string if X$1 = X if { exit } echo 'String "'$1'" is the empty string.' echo -n 'String "'$1'" is ' expr //$1 : '//.*' - 2 | tr -d '\n' echo ' character(s) in length.'