BASENAME(1)
๐ BASENAME(1) ๐
okay bestie, welcome to basename โ a User Commands classic, and honestly? iconic. โจ
๐ NAME ๐
basename โ strip directory and suffix from filenames. that's it. that's the whole job. and she does it flawlessly. ๐
๐ธ SYNOPSIS ๐ธ
basename NAME [SUFFIX]
basename OPTION... NAME...
two whole modes, pick your fighter. ๐ซถ
๐ฆ DESCRIPTION ๐ฆ
So here's the vibe: basename prints NAME with any leading directory components removed. just straight up yeets the whole path prefix. bye. ๐ฎ
And if you specified a trailing SUFFIX, she'll remove that too. double slay. โจ
real talk though: mandatory arguments to long options are mandatory for short options too. no shortcuts on the shortcuts, bestie. ๐
โจ the options, one by one โจ
-a,--multipleโ support multiple arguments and treat each as aNAME. plural girlies rise ๐-s,--suffix=SUFFIXโ remove a trailingSUFFIX; implies-a. yes she does it all by herself, no extra flag needed ๐-z,--zeroโ end each output line withNUL, not newline. for the chaotic gremlins who need NUL-separated output ๐--helpโ display this help and exit. she's helpful AND humble ๐ญ--versionโ output version information and exit. main character moment ๐
๐ EXAMPLES ๐
these are literally so good, look:
basename /usr/bin/sort -> "sort"
basename include/stdio.h .h -> "stdio"
basename -s .h include/stdio.h -> "stdio"
basename -a any/str1 any/str2 -> "str1" followed by "str2"
see how -s .h and the plain positional .h do the exact same thing?? lowkey the same energy. and -a just eats a whole list of them and spits out "str1" followed by "str2". ate. ๐ฅ
๐ AUTHOR ๐
Written by David MacKenzie. thank you king, we owe you everything ๐ซถ
๐ REPORTING BUGS ๐
found something cursed? 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. fr fr, no cap, don't come for them if it breaks ๐ญ
๐ SEE ALSO ๐
dirname(1)โ her sister, does the opposite thing, equally iconicreadlink(1)
Full documentation <https://www.gnu.org/software/coreutils/basename> or available locally via: info '(coreutils) basename invocation'
and that's the whole page bestie!! ๐โจ this was GNU coreutils 9.12, dated September 2026 โ manual page BASENAME(1), aka the cutest little path-stripper in the whole toolkit. go forth and strip. ๐๐ฆ
๐ฆ 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