Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ basename(1) — Ultrix/UWS 4.1 RISC

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dirname(1)

ex(1)

sh(1)

basename(1)

Name

basename − strip directory names from pathname

Syntax

basename string [ suffix ]

Description

The basename command deletes from string any prefix ending in a slash (/) and the suffix, and prints the result on the standard output.  The basename command also handles limited regular expressions in the same manner as ed(.). The basename command is often used inside substitution marks (` `) within shell procedures. 

Examples

The following example shell script compiles the file /usr/src/bin/cat.c and moves the output to cat in the current directory:

cc /usr/src/bin/cat.c
mv a.out `basename $1 .c`

The following example echoes only the base name of the file /etc/syslog.conf by removing the prefix and any possible sequence of characters following the period in the file’s name:

% basename /etc/syslog.conf "..*"
syslog

See Also

dirname(1), ex(1), sh(1)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026