alue of the variable as a character string. For example, if filename has the value fred.c, then ${#filename} would have the value 6.
The other operator ($... } is actually equivalent to the UNIX utility basename(1). basename takes a pathname as argument and returns the filename only; it is meant to be used with the shell's co... s.
Background
In traditional Bourne shell programming you might see references to the basename and dirname commands. These perform simple string manipulati... a.filename
Notice that the GNU version of basename takes an optional parameter. This handy for specifying a filename "extension" like .tar.gz which will be stripped
ty: zmore "" arg2 arg3
then
echo "Usage: `basename $0` filename" >&2
# Error message to stderr.
exit $E_NOAR... (error code).
fi
filename=$1
if [ ! -f "$filename" ] # Quoting $filename allows for possible spaces.
then
echo "File $filename not found!" >&2 # Error message to stderr.
exit $E_NOTFOUND
fi
if [ ${filename##*.} != "gz" ]
# Using bracket in variable subst