The basename(1) utility treats the string argument
as a path name. The string is converted to the file name
corresponding to the last path-name component in string and
then the suffix string, if present, is removed. The
basename utility does this by performing actions equivalent
to the following steps in order:
If string consists entirely of slash (/)
characters, string is set to a single slash character, and
the remaining steps are skipped.
If there are any trailing slash characters in string,
they are removed.
If there are any slash characters remaining in string,
the prefix of string up to and including the last slash
character in string is removed.
If the suffix operand is present, is not identical to
the characters remaining in string, and is identical to a
suffix of the characters remaining in string, the
suffix string is removed from the end of string.
Otherwise, string is not modified by this step. It is not
considered an error if suffix is not found in
string.
The resulting string is written to standard output.
The basename(1) utility exits 0 on success, and >0 if
an error occurs.