Many people use the basename program to obtain the base name of a full pathname, such as in (using the Borne Shell sytax):
Pathname=/usr/bin/archibaldA far more efficient method, which doesn't require a new process (a very expensive OS task) nor extra memory space, is to use the powerful Shell built-in variable substitution. Thus the above can be done simply by:
Filename=`basename $FILE`
Pathname=/usr/bin/archibaldIf basename is used in many places, this can provide a significant benefit.
Filename="${Filename##*/}"
Mac OS X Hints
http://hints.macworld.com/article.php?story=20020902071324228