BASENAME(C) XENIX System V BASENAME(C)
Name
basename - Removes directory names from pathnames.
Syntax
basename string [ suffix ]
Description
basename deletes any prefix ending in / and the suffix (if
present in string) from string, and prints the result on the
standard output. The result is the ``base'' name of the
file, i.e., the filename without any preceding directory
path and without an extension. It is used inside
substitution marks (``) in shell procedures to construct new
filenames.
The related command dirname deletes the last level from
string and prints the resulting path on the standard output.
Examples
The following command displays the filename memos on the
standard output:
basename /usr/johnh/memos.old .old
The following shell procedure, when invoked with the
argument /usr/src/cmd/cat.c, compiles the named file and
moves the output to a file named cat in the current
directory:
cc $1
mv a.out `basename $1 .c`
See Also
dirname(C), sh(C)
Page 1 (printed 2/7/91)