Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
dirname(1) OSS Shell and Utilities Reference Manual
NAME
dirname - Returns specified parts of pathnames
SYNOPSIS
dirname string
DESCRIPTION
The dirname command reads the string specified on the command line, deletes from the last
/ (slash) to the end of the line, and writes the remaining pathname to standard output.
The dirname command is generally used inside command substitutions within a shell procedure
to specify an output filename that is some variation of a specified input filename.
EXAMPLES
1. To construct the name of a file located in the same directory as another, enter:
AOUTFILE=‘dirname $TEXTFILE‘/a.out
This command sets the AOUTFILE shell variable to the name of an a.out file in the
same directory as TEXTFILE.IfTEXTFILE is /u/fran/prog.c, then the value of dir-
name $TEXTFILE is /u/fran, and AOUTFILE becomes /u/fran/a.out.
RELATED INFORMATION
Commands: basename(1), sh(1).
3−16 Hewlett-Packard Company 527188-007