shellspells beta


dirname NAME

dirname prints NAME with its trailing /component removed.

Often used in shell scripts to get the directory component of a file.


Get the directory component

$ dirname .gnome2/keyrings/default.keyring

Get the full path to a file even if the file was supplied with a relative path

$ FULLPATH=.gnome2/keyrings/default.keyring
$ echo $(pwd $(dirname $FULLPATH))/$(dirname $FULLPATH)

Related commands: basename