The basename command deletes any prefix ending with the last slash "/" character present in string and also a suffix.

Usage

The default basename command syntax is:
basename [flags] [string] [suffix]
Where [flags] are the cat flags, read below for more info, the string command is the pathname and the suffix, if indicated, will be also deleted.

Flags

Here are some of the most common basename flags:
  • -a: Every aregument is treated as a string
  • -s: The suffix is taken as its argument
  • -a: Supports multiple arguments and they will be treated as a name

Example

basename /USI/command
The shell will output this:
command