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 with NUL rather 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