Basename
From Wikipedia, the free encyclopedia
basename
is a common program found on Unix systems; typically it is the GNU Project's coreutils version, which is Free software. Given a pathname, it will return the name of the file that the pathname refers to. For example, basename /home/john/pictures/cat.jpg
will return "cat.jpg". While this may seem trivial and useless to humans, basename is a useful tool in shell scripts.
A related command is dirname
, which returns the directory name without the filename. For example, dirname /home/john/pictures/cat.jpg
will return "/home/john/pictures"