dirname

display directory components of path name 

Command, KornShell Built-in


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:

On Windows systems, these rules handle forward slashes in the same way as backslashes.

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.


NOTE

dirname is provided as both an external utility and a built-in MKS KornShell utility.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 2000. Windows XP. Windows Server 2003. Windows Vista.

On Windows systems, dirname removes the final backslash or slash and all following characters. On UNIX and POSIX-compliant systems, backslash is a valid file name character and is not stripped.


AVAILABILITY

MKS Toolkit for Power Users
MKS Toolkit for System Administrators
MKS Toolkit for Developers
MKS Toolkit for Interoperability
MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
basename, pathchk, sh


MKS Toolkit 9.2 Documentation Build 16.