DIRNAME(1)

πŸ“¦
version 9.10 Β· 5 versions
, in ubuntu stonking

πŸ’– DIRNAME(1) πŸ’–

okay bestie, pull up a chair, we're talking about dirname from the GNU coreutils manual β€” it's a User Command, it's iconic, it's literally the girl who tells you where you actually are.


✨ NAME ✨

dirname β€” strip last component from file name πŸŽ€


🌸 SYNOPSIS 🌸

dirname [OPTION] NAME...

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: you hand dirname one or more NAMEs, and it hands you back each NAME with its last non-slash component removed, and any trailing slashes removed too. like, the whole last chunk just. gone. bye. πŸ’…

and if a NAME has no / characters in it at all? then dirname gives you . β€” which means the current directory, in case that wasn't obvious. no slash, no party, just . 🫢

✨ OPTIONS ✨

  • -z, --zero β€” end each output line with NUL, not newline ✨ (-z is giving "no newlines, we're NUL-maxxing", fr fr)
  • --help β€” display this help and exit πŸ‘‘
  • --version β€” output version information and exit ⭐

🌈 EXAMPLES 🌈

okay watch this, these are the examples and they ate:

dirname /usr/bin/
       -> "/usr"
dirname dir1/str dir2/str
       -> "dir1" followed by "dir2"
dirname stdio.h
       -> "."

the last one is lowkey sending me β€” stdio.h has zero slashes so it just goes "." and moves on. main character behavior honestly 😭


πŸ’œ AUTHOR πŸ’œ

Written by David MacKenzie and Jim Meyering. legends, genuinely. periodt.


πŸŽ€ REPORTING BUGS πŸŽ€

found a bug? don't suffer in silence bestie, report it:


🌟 SEE ALSO 🌟

Full documentation <https://www.gnu.org/software/coreutils/dirname> or available locally via: info '(coreutils) dirname invocation'

Packaged by Ubuntu (9.10-1ubuntu2)

Copyright Β© 2026 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

no cap β€” that "NO WARRANTY" part is real and it's in CAPS for a reason, bestie. read it. πŸ™ˆ

okay that's the whole page, and the sign-off is literally the footer: this was GNU coreutils 9.10, from August 2026, and you're reading DIRNAME(1) β€” go split some paths, you've got this πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from