BASENAME(1) General Commands Manual BASENAME(1)

basenameprint last path component of a path

basename [-z] [path] [suffix]

basename [-az] [-s suffix] [path...]

basename prints the last path component of path with removing any trailing slashes as well as trailing suffix when applicable.

When path isn't given or is an empty string “.” is printed.

Support multiple path arguments
suffix
Set suffix; implies -a
Use NULL as separator for each result instead of newline.

The basename utility exits 0 on success, and >0 if an error occurs.

dirname(1), basename(3)

basename should be compliant with the IEEE Std 1003.1-2024 (“POSIX.1”) specification.

The -a, -s and -z options are extensions inspired by GNU coreutils.

Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>

2024-07-28 Linux 6.6.67-gentoo-x86_64