basename

Returns non-directory portion of a pathname.

Install

All systems
curl cmd.cat/basename.sh
Debian Debian
apt-get install coreutils
Ubuntu
apt-get install coreutils
Alpine
apk add coreutils
Arch Arch Linux
pacman -S coreutils
image/svg+xml Kali Linux
apt-get install coreutils
CentOS
yum install coreutils
Fedora
dnf install coreutils
OS X
brew install coreutils
Raspbian
apt-get install coreutils
Docker
docker run cmd.cat/basename basename powered by Commando

Returns non-directory portion of a pathname.

  • Show only the file name from a path:
    basename path/to/file
  • Show only the file name from a path, with a suffix removed:
    basename path/to/file suffix

© tl;dr; authors and contributors