Name

dirname path — coreutils

Synopsis

/usr/bin stdin stdout - file -- opt --help --version

The dirname command removes the final component from a file path:

$ dirname /users/smith/mydir
/users/smith

dirname simply manipulates a string that is a directory name. It does not change your current working directory.

Get Linux Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.