BASENAME(1)
π BASENAME β the basename(1) girlies' guide π
okay so bestie, welcome to basename β the GNU coreutils glow-up that takes a whole dramatic file path and hands you just the pretty little name at the end. she's simple, she's iconic, she's been carrying dirname(1)'s sister act since forever. let's get into it π
β¨ NAME β¨
basename β strip directory and suffix from filenames π¦
πΈ SYNOPSIS πΈ
basename NAME [SUFFIX]
basename OPTION... NAME...
π DESCRIPTION π
Print NAME with any leading directory components removed. If you say so, she'll also remove a trailing SUFFIX. that's it. that's the whole vibe. no cap. π
π‘ friendly reminder bestie: Mandatory arguments to long options are mandatory for short options too. so like, don't skip the value on -s, she needs it fr fr.
π«Ά OPTIONS π«Ά
-a,--multipleβ support multiple arguments and treat each as aNAMEπ―ββοΈ (yes queen, she can handle a whole group chat at once)-s,--suffix=SUFFIXβ remove a trailingSUFFIX; implies-aβ οΈ (so this one auto-unlocks the multiple-args mode, sneaky but cute)-z,--zeroβ end each output line withNUL, not newline π« (for when you want your pipeline to be Null-separated, iykyk)--helpβ display this help and exit πββοΈ--versionβ output version information and exit π
π EXAMPLES π
here's where she really eats, no crumbs left:
basename /usr/bin/sort
-> "sort"
directory drama detached, just "sort" remains. periodt.
basename include/stdio.h .h
-> "stdio"
she took off the include/ and the .h in one go. dual-wielding. iconic. π
basename -s .h include/stdio.h
-> "stdio"
same energy, but now the suffix removal is doing the work itself via -s .h. chef's kiss β¨
basename -a any/str1 any/str2
-> "str1" followed by "str2"
-a said "I can do both" and she DID. "str1" followed by "str2". π
πΌ AUTHOR πΌ
Written by David MacKenzie. π«Ά thank you for the gift, king.
π REPORTING BUGS π
found a bug? don't be shy, tell the girlies:
- Report bugs to:
bug-coreutils@gnu.org - GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
- General help using GNU software: <https://www.gnu.org/gethelp/>
- Report any translation bugs to <https://translationproject.org/team/>
π₯ SEE ALSO π₯
dirname(1)β her sibling. complementary queen πreadlink(1)β also does path things, different flavour π
Full documentation <https://www.gnu.org/software/coreutils/basename> or available locally via: info '(coreutils) basename invocation'
Packaged by Ubuntu (9.10-1ubuntu2) π¦ 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.
π¨ IMPORTANT bestie: There is NO WARRANTY, to the extent permitted by law. she's free, she's generous, she's not legally responsible for your rm -rf situation. π
and that's the tea, babe π΅π β this whole glow-up came to you from GNU coreutils 9.10, dated August 2026, page BASENAME(1). go strip some directories, you main character πβ¨ππ¦πΈ
π¦ where this page comes from
- ubuntu stonking: gnu-coreutils 9.10-1ubuntu2 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms