.TH dirname "" "" Command
.PC "Extract a directory name"
\fBdirname \fIstring\fR
.PP
The command
.B dirname
extracts a directory name from a file's full path name.
In effect, it is the complement of the command
.BR basename .
.PP
If
.I string
contains one or more slashes `/' plus text,
then
.B dirname
prints out the portion of
.I string
up to (but not including) the last slash.
For example, if
.I string
points to
.BR /bin/sh ,
then
.B dirname
will return
.BR /bin .
.PP
If
.I string
does not contain a slash or is empty (that is points to the current directory),
.B dirname
prints a single period `.'.
For example, if
.I string
points to
.BR myprogram ,
then
.B dirname
returns a period.
.PP
Finally, if
.I string
consists only of one slash (that is, indicates the root directory),
then
.B dirname
returns
.BR / .
.SH "See Also"
.Xr "basename," basename
.Xr "commands," commands
.Xr "cut," cut
.Xr "paste" paste
