DIRNAME(1)

๐Ÿ’… DIRNAME(1) โ€” like, the user commands manual, bestie โœจ

okay so this is dirname, section 1 of the manual (user commands, the fun section), and honestly? she's a tiny little legend and you're gonna love her ๐Ÿซถ


๐ŸŒธ NAME ๐ŸŒธ

dirname โ€” strip the last component off a file name. that's it. that's the whole job. iconic behavior ๐Ÿ’–


โœจ SYNOPSIS โœจ

dirname [OPTION] NAME...

yes bestie, you can throw multiple NAMEs at her at once. she can handle it ๐Ÿ’…


๐ŸŽ€ DESCRIPTION ๐ŸŽ€

So here's the tea: dirname takes each NAME you hand her and prints it back to you with the last non-slash component gone, and any trailing slashes gone too. bye bye last bit ๐Ÿ‘‹

And if a NAME has, like, literally zero / characters in it? Then she prints . โ€” which means the current directory, iykyk ๐Ÿฆ‹

  • -z, --zero โ€” ends every output line with a NUL character instead of a newline. not me being obsessed with NUL-separated output for scripting ๐Ÿ˜ญโœจ
  • --help โ€” shows you the help text and dips out. display this help and exit, fr fr
  • --version โ€” spits out the version info and exits. output version information and exit ๐Ÿ‘‘

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

the receipts, as requested:

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

see how dirname stdio.h just gives you .? no slashes, no last-component-to-strip, so she says "current directory, babe" ๐Ÿ’€ adorable. and yes, dirname dir1/str dir2/str gives you two lines of output โ€” "dir1" followed by "dir2" ๐ŸŽ€


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Written by David MacKenzie and Jim Meyering. legends. we stan. ๐Ÿ’œ


๐Ÿ› REPORTING BUGS ๐Ÿ›

found a bug? don't suffer in silence bestie, tell the people:


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. โš ๏ธ like, none. zero. nada. don't come for her if something breaks, she warned you fr ๐Ÿ’€

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

Full documentation <https://www.gnu.org/software/coreutils/dirname> โ€” or available locally via: info '(coreutils) dirname invocation' ๐Ÿ“–โœจ


and that's the whole vibe check, bestie โ€” this page is from GNU coreutils 9.12, dated September 2026, and it ate, no cap ๐Ÿ’…๐ŸŒธ๐Ÿซถ

๐Ÿ“ฆ where this page comes from