O'Reilly logo

Linux® Desk Reference, Second Edition by Scott Hawkins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Commands

basename

NAME [SUFFIX]

This command takes a full UNIX path and displays only the last element. It is generally used in scripting. If the optional suffix is supplied and it matches the last element, it is stripped away as well.

Example: Suppose your current working directory is /var/spool/ mail. In that case,

basename $PWD

would display

mail

Of course, basename can be used on text strings as well as environment variables, and

basename /var/spool/mail

would also display

mail

--help Display usage information.
--version Display version information.

dirname

NAME

This command takes a full UNIX path and displays all but the last element. The command is generally used in scripting.

Example: Suppose you were writing a script that needed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required