home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: banner Chapter 2
UNIX Commands
Next: Reference: batch
 

basename



basename

 

pathname

 [

suffix

]

Given a pathname , strip the path prefix and leave just the filename, which is printed on standard output. If specified, a filename suffix (e.g., .c ) is removed also. basename is typically invoked via command substitution ( ` ` ) to generate a filename. See also dirname .

Example

Given the following fragment from a Bourne shell script:

prog_name="`basename $0`"
echo "$prog_name: QUITTING: can't open $ofile"/
     1>&2 ; exit 1

If the script is called do_it , then the following message would be printed on standard error:

do_it: QUITTING: can't open output_file


Previous: Reference: banner UNIX in a Nutshell: System V Edition Next: Reference: batch
Reference: banner Book Index Reference: batch

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System