Basename

From LQWiki
Jump to navigation Jump to search

basename returns the name of a file, minus the directories leading up to it.

For example:

$ basename "foo/bar/baz"
baz

basename retains the part removed by dirname.

Provided by

Most (all?) Linux distributions incorporate this from the GNU Coreutils: and use its man page

Related Commands

  • dirname - get the directory part of a pathname.
  • pathchk - check for strange names
  • mktemp - Create a temporary

See also

shell scripting

This article is a stub and needs to be finished. Plunge forward and help it grow!