Given a pathname
, strip the path prefix and leave just the filename, which is printed on standard output. If specified, a filename suffix
The Solaris version of basename allows the suffix to be a pattern of the form accepted by expr . See the entry for expr for more details.
Given the following fragment from a Bourne shell script:
ofile=output_file myname="`basename $0`" echo "$myname: QUITTING: can't open $ofile" 1>&2 exit 1
If the script is called do_it , the following message would be printed on standard error:
do_it: QUITTING: can't open output_file