DIRNAME(1)
π dirname(1) β the General Commands Manual one π
okay bestie, so this is dirname from the General Commands Manual, section 1, and it does exactly one thing and does it flawlessly: it strips the last component off a file name. that's it. that's the whole personality. π
β¨ NAME β¨
dirname β strip last component from file name π¦
β¨ SYNOPSIS β¨
dirname [OPTION] NAME...
β¨ DESCRIPTION β¨
Strip last component from file name. no cap, that's literally the job. you hand it a path, it hands you back the path without the last bit. iconic behavior honestly. π
β¨ OPTIONS β¨
-z,--zeroβ separate output withNULrather than newline π«Ά (NUL instead of the lil newline, great for when newlines would be messy)-h,--helpβ Print help π-V,--versionβ Print version β
β¨ EXTRA β¨
here's the real tea, bestie π β it outputs each NAME with its last non-slash component and trailing slashes removed. and if a NAME contains no /'s at all? it just outputs . (meaning the current directory). so it never leaves you hanging, periodt. π
β¨ VERSION β¨
v(uutils coreutils) 0.12.0 πΈ
β¨ EXAMPLES β¨
calculate the parent directory of a given path:
dirname path/to/file_or_directory
calculate the parent directory of multiple paths:
dirname path/to/file_or_directory1 path/to/file_or_directory2 ...
delimit output with a NUL character instead of a newline (useful when combining with xargs):
dirname [-z|--zero] path/to/file_or_directory1 path/to/file_or_directory2 ...
the examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License π also, heads up: as uutils is a work in progress, some examples might fail π not me warning you though, fr fr.
and that's the whole page, babe β¨ authored under the uutils coreutils umbrella, version v(uutils coreutils) 0.12.0, dated 2026-09-25, and yeah it's DIRNAME(1) through and through. slay, go strip some components π
πΈπ
π¦ where this page comes from
- ubuntu stonking: rust-coreutils 0.12.0-1ubuntu2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms