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:
- Report bugs to: <bug-coreutils@gnu.org>.
- Report any translation bugs to: <https://translationproject.org/team/>.
- GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
- General help using GNU software: <https://www.gnu.org/gethelp/>
๐ COPYRIGHT ๐
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
- arch rolling: coreutils 9.12-2 ยท GPL-3.0-or-later AND GFDL-1.3-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms