basename(1) CLIX basename(1)
NAME
basename, dirname - Delivers portions of pathnames
SYNOPSIS
basename string [suffix],
dirname string
DESCRIPTION
The basename command delivers portions of pathnames. The command deletes
any prefix ending in / and the suffix (if present in string) from string,
and displays the result on stdout. It is normally used inside
substitution marks (`...`) within shell procedures.
The dirname command delivers all but the last level of the pathname in
string.
EXAMPLES
1. The following example, 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'`
2. To set the shell variable $NAME to /usr/src/cmd:
NAME=`dirname /usr/src/cmd/cat.c`
EXIT VALUES
The basename and dirname commands return values of 0 if successful. If
unsuccessful, these commands return values of 1.
RELATED INFORMATION
Commands: acc(1), cc(1), sh(1)
2/94 - Intergraph Corporation 1