basename - strip directory and suffix from filenames
basename [ options ] string [suffix]
basename [ options ] string ...
removes all leading directory components from the file name defined by string
. If the file name defined by
has a suffix that ends in suffix
, it is removed as well.
If string consists solely of / characters the output will be a single / unless PATH_LEADING_SLASHES
returned by getconf(1) is 1 and string consists of multiple /
characters in which case // will be output. Otherwise, trailing / characters are removed, and if there are any
remaining / characters in string, all characters up to and including the last / are removed. Finally, if suffix
is specified, and is identical the end of string, these characters are removed. The characters not removed from string
will be written on a single line to the standard output.
- -a, --all
All operands are treated as string and each modified pathname is printed on a separate line
on the standard output.
- -s, --suffix=suffix
All operands are treated as string and each modified pathname, with suffix
removed if it exists, is printed on a separate line on the standard output.
- Successful Completion.
An error occurred.