BASENAME(1)
π BASENAME(1) β bestie edition β¨
okay so this is the manual page for basename, living in the General Commands Manual section (that's section 1, for the uninitiated π). it's a little icon, it does one thing, and it does it gorgeously.
β¨ NAME β¨
basename β print NAME with any leading directory components removed. If specified, also remove a trailing SUFFIX. π
that's it. that's the whole job. and yet. she serves. π
πΈ SYNOPSIS πΈ
basename [-z] NAME [SUFFIX]
basename OPTION... NAME...
two whole modes, bestie. the classic one and the options girl one. π¦
π DESCRIPTION π
Print NAME with any leading directory components removed. If specified, also remove a trailing SUFFIX.
fr fr that's the entire description, they really said "we're not gonna pad this." and honestly? respect. π«Ά
π OPTIONS π
-a,--multipleβ support multiple arguments and treat each as a NAME. so you can just dump a whole list of paths in there and she'll handle all of them. no cap. π₯-s,--suffix <SUFFIX>β remove a trailing SUFFIX. also, plot twist: this one implies-a, so you're automatically in multiple-argument mode whether you asked for it or not. β¨-z,--zeroβ end each output line with NUL, not newline. for when newlines are simply not the vibe. π§-h,--helpβ Print help. she'll tell you what's up. π-V,--versionβ Print version. ~receipts~ π
β VERSION β
v(uutils coreutils) 0.12.0
that's the version bestie. that's what -V is gonna hand you. π
π EXAMPLES π
Show only the file name from a path:
basename path/to/file
Show only the rightmost directory name from a path:
basename path/to/directory
Show only the file name from a path, with a suffix removed:
basename path/to/file suffix
ngl, credit where credit is due: The examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. Also please note that, as uutils is a work in progress, some examples might fail. π not her fault, she's growing. π
and that's the whole page, no crumbs left. π
this was BASENAME(1) from the v(uutils coreutils) 0.12.0 era, dated 2026-09-25. go forth and strip those directory components, you absolute main character. periodt. πβ¨π
π¦ 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