Navigation

basename

Prints the final component of a path.

basename strips leading directory components and optionally a suffix. It is commonly used in shell scripts.

Syntax
basename path [suffix]

Arguments explained

  • Options adjust output or behavior.
  • Arguments name the files, services, hosts, or values the command should work with.

Common examples

Get a filename
basename /var/log/syslog

Prints syslog.

Remove an extension
basename archive.tar.gz .tar.gz

Prints archive.

basename Command
FieldDetails
Commandbasename
CategoryNavigation
Primary usePrints the final component of a path.
Syntaxbasename path [suffix]