Returns the base file name of a string parameter.
basename String [ Suffix ]
The basename command reads the String parameter, deletes any prefix that ends with a / (slash) and any specified Suffix parameter, and writes the remaining base file name to standard output. The basename command applies the following rules in creating the base file name:
K > basename /u/dee/desktop/cns.boo cns.boocns.booK > basename /u/dee/desktop/cns.boo .boocnsThe basename and dirname commands are generally used inside command substitutions within a shell script to specify an output file name that is some variation of a specified input file name.
This command returns the following exit values:
| Item | Description | 
|---|---|
| 0 | Successful completion. | 
| >0 | An error occurred. | 
basename $WORKFILEOFILE=`basename $1 .c`.oNote: The ` (grave accent) specifies command substitution.
| Item | Description | 
|---|---|
| /usr/bin/basename | Contains the basename command. |