DIRNAME(C) XENIX System V DIRNAME(C)
Name
dirname - Delivers directory part of pathname.
Syntax
dirname string
Description
dirname delivers all but the last component of the pathname
in string and prints the result on the standard output. If
there is only one component in the pathname, only a ``dot''
is printed. It is normally used inside substitution marks
(``) within shell procedures.
The companion command basename deletes any prefix ending in
a slash (/) and the suffix (if present in string) from
string, and prints the result on the standard output.
Examples
The following example sets the shell variable NAME to
/usr/src/cmd:
NAME=`dirname /usr/src/cmd/cat.c`
This example prints /a/b/c on the standard output:
dirname /a/b/c/d
This example prints a ``dot'' on the standard output:
dirname file.ext
See Also
basename(C), sh(C)
Page 1 (printed 2/7/91)