Previous | Table of Contents | Next |
DESCRIPTION
The external dirname command parses the given path and returns only the pathname. Its cousin command basename returns the filename. Any suffix after the last / (slash) is deleted from the path, including the /. For instance, the command
cj> dirname /u1/ts/mylogin/junk.c
returns
/u1/ts/mylogin
The entire path (/ul/tech/mylogin) is returned but the filename junk.c is removed, along with the / separating the parent path and the filename.
COMMAND FORMAT
The format of the dirname command follows .
dirname path
Arguments
Only one argument may be passed to the dirname command.
path | The path that is parsed and only the pathname is returned. The filename is removed. |
RELATED COMMANDS
Refer to the basename command described in Module 18.
RELATED FILES
The dirname command writes to the standard output.
APPLICATIONS
The dirname command is normally used as a substitution command within a shell script. It can be used to reduce a full path parameter or variable down to a path without the filename.
TYPICAL OPERATION
In this activity you use the dirname command to find the directory of a command. Begin at the shell prompt.
Previous | Table of Contents | Next |