BASENAME(1)

NAME

basename, dirname - return filename or directory portion of pathname

SYNOPSIS

basename string [.suffix]

dirname path

DESCRIPTION

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 ignored.

Dirname deletes the filename portion, beginning with the last slash or colon : character to the end of string, and writes the result to the standard output.

EXAMPLES

The following line sets the shell variable FOO to /usr/bin.

FOO=`dirname /usr/bin/trail`

Both the basename and dirname exit 0 on success, and >0 if an error occurs.

NOTES

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 deliminator.

SEE ALSO

csh(1), sh(1), basename(3)

STANDARDS

The basename and dirname functions are expected to be POSIX 1003.2 compatible.

COPYRIGHT
This program contains material from the ORCA/C Run-Time Libraries, copyright 1987-1992 by ByteWorks, Inc. Used with Permission.