dirname
dirname NAME
dirname prints NAME with its trailing /component removed.
Often used in shell scripts to get the directory component of a file.
Examples
Get the directory component
$ dirname .gnome2/keyrings/default.keyring .gnome2/keyrings
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) /home/garry/.gnome2/keyrings
Related commands: basename