Search notes:

Shell command: basename

basename prints the trailing part of a filesystem path. Optionally, it can remove a suffix as well.

Print last part of path

basename  relative/path/to/a/file      # file
basename  relative/path/to/a/file.txt  # file.txt
basename  relative/path/to/a/          # a
basename /absolute/path/to/a/file      # file
basename /absolute/path/to/a/file.txt  # file.txt
basename /absolute/path/to/a/          # a
Github repository shell-commands, path: /basename/remove-directory

Remove last part of path and optionally remove suffix

basename  relative/path/to/a/file      .txt  # file
basename  relative/path/to/a/file.txt  .txt  # file
basename  relative/path/to/a/          .txt  # a
basename /absolute/path/to/a/file      .txt  # file
basename /absolute/path/to/a/file.txt  .txt  # file
basename /absolute/path/to/a/          .txt  # a
Github repository shell-commands, path: /basename/remove-directory-and-suffix

See also

Shell commands such as dirname
Perl module File::Basename

Index