man > dirname(1)

πŸ“› NAME

dirname - strip last component from file name

πŸš€ Quick Reference

Use CaseCommandDescription
πŸ“‚ Get directory from pathdirname /path/to/fileOutputs the directory portion of the path
πŸ”— Strip trailing slashdirname /path/to/dir/Removes trailing slash and last component
πŸ“„ File with no slashdirname filenameOutputs "." (current directory)
πŸ“¦ Multiple namesdirname dir1/str dir2/strProcesses multiple arguments, outputting each directory
πŸ”š Zero‑separated outputdirname -z file1 file2Outputs NUL‑terminated strings for scripting

πŸ“– SYNOPSIS

dirname [OPTION] NAME...

πŸ“ DESCRIPTION

Output each NAME with its last non‑slash component and trailing slashes removed; if NAME contains no /'s, output '.' (meaning the current directory).

πŸ”Ή -z, --zero

πŸ”š end each output line with NUL, not newline

❓ --help

❓ display this help and exit

πŸ“‹ --version

πŸ“‹ output version information and exit

πŸ’‘ EXAMPLES

dirname /usr/bin/
-> "/usr"

πŸ“‚ Strips the last component, leaving the directory path.

dirname dir1/str dir2/str
-> "dir1" followed by "dir2"

πŸ“ Processes multiple names, outputting each directory part.

dirname stdio.h
-> "."

βšͺ No slashes, so outputs the current directory symbol.

πŸ‘€ AUTHOR

Written by David MacKenzie and Jim Meyering.

πŸ› REPORTING BUGS

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>

©️ COPYRIGHT

Copyright Β© 2020 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.

πŸ“š SEE ALSO

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

dirname(1)
πŸ“› NAME πŸš€ Quick Reference πŸ“– SYNOPSIS πŸ“ DESCRIPTION
πŸ”Ή -z, --zero ❓ --help πŸ“‹ --version
πŸ’‘ EXAMPLES πŸ‘€ AUTHOR πŸ› REPORTING BUGS ©️ COPYRIGHT πŸ“š SEE ALSO

Generated by phpman v4.9.25-25-g40dbf62 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-16 13:50 @2600:1f28:365:80b0:8802:8bb4:3873:328e
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format