dirname(1) MPE/iX Shell and Utilities dirname(1)
______________________________________________________________________
NAME
dirname -- display directory components of path name
SYNOPSIS
dirname pathname
DESCRIPTION
dirname strips off the trailing part of a file name. The result
is the path name of the directory that contains the file. This
is useful in shell scripts.
Note: dirname makes no attempt to validate the path name; for
validation, use pathchk(1).
dirname follows these rules:
* If pathname is //, return it.
* Otherwise, if it is all slashes, return one slash.
* Otherwise, remove all trailing slashes.
* If there are no slashes remaining in pathname , return period
(.).
* Otherwise, remove trailing non-slash characters.
* If the remaining string is //, return it.
* Otherwise, remove any trailing slashes.
* If the resulting string is empty, return period (.).
* Otherwise, return the resulting string.
EXAMPLES
The command
dirname src/lib/printf.c
produces
src/lib
DIAGNOSTICS
Possible exit status values are:
0 Successful completion.
1
dirname(1) MPE/iX Shell and Utilities dirname(1)
______________________________________________________________________
PORTABILITY
POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems.
SEE ALSO
basename(1), pathchk(1)
2