dirname - Return directory portion of path name

Synopsis

dirname string

Description

You can use dirname to delete the filename portion, beginning with the last slash character (/) to the end of string, and write the result to standard output. The string is processed using the following rules:

Operands

The string operand is the pathname of which dirname will return the directory portion of.

Exit Status

Related information

Examples
  1. Set the shell variable FOO to "/usr/bin".
    FOO=$(dirname /usr/bin/trail)