BASENAME(1) Commands and Applications BASENAME(1)
basename, dirname - return filename or directory portion of pathname
basename string [.suffix]
Basename deletes any prefix ending with the last slash or colon :
character present in string, and a suffix, if given. The resulting
filename is written to the standard output. Any trailing slash or
colon : characters in string will be removed. A non-existent suffix is
Dirname deletes the filename portion, beginning with the last slash or
colon : character to the end of string, and writes the result to the
The following line sets the shell variable FOO to /usr/bin.
Both the basename and dirname exit 0 on success, and >0 if an error
Because these programs use basename(3) and dirname(3) respectively,
there is a preference on ':' as a deliminator. Additionally, if a ':'
is used anywhere in the pathname, it will be considered the delimina-
csh(1), sh(1), basename(3)
The basename and dirname functions are expected to be POSIX 1003.2 com-
This program contains material from the ORCA/C Run-Time Libraries,
copyright 1987-1992 by ByteWorks, Inc. Used with Permission.
GNO 25 March 1998 BASENAME(1)
Man(1) output converted with