basename

NAME

basename - Windows command-line utility to return file-name portion of path name

SYNOPSIS

basename string [suffix]

DESCRIPTION

The basename Windows command-line 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 command does this by performing actions equivalent to the following steps, in order:

  1. If string consists entirely of a combination of slash (/) or backslash (\) characters, string is set to the last character in string, and the remaining steps are skipped.
  2. If there are any trailing slash or backslash characters in string, they are removed.
  3. If there are any slash or backslash characters remaining in string, the prefix of string up to and including the last slash or backslash character in string is removed.
  4. 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(1w) command exits 0 on success, and >0 if an error occurs.