dirname

display directory components of path name

Command


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 the pathchk command.

dirname follows these rules:
Note:

dirname returns device names as you type them in pathname -- if you include a slash, dirname returns the device name with the following slash; if you don't include a slash, the device name is returned with no following slash.


EXAMPLES

The command
dirname src/lib/printf.c
produces
src/lib


DIAGNOSTICS

Possible exit status values are:
0

Successful completion.

>0

An error occurred.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0.

On UNIX and POSIX-compliant systems, backslash is a valid file name character and is not stripped.


SEE ALSO

Commands:
basename, pathchk


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]