Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ basename(1) — A/UX 3.0.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sh(1)




basename(1) basename(1)
NAME basename, dirname - get part of a pathname SYNOPSIS basename string [suffix] dirname string ARGUMENTS string Specifies an absolute or a relative pathname. suffix Specifies an optional suffix that, if present in string, basename is to remove. DESCRIPTION basename examines string for the last slash (/) and returns the characters that follow the slash. For example, basename /usr/bin/vi yields vi. dirname examines string for the last slash and returns the characters that precede the slash. For example, dirname /usr/bin/vi yields /usr/bin. Both basename and dirname write on the standard output. Neither command verifies that string is a valid pathname on the current system. EXAMPLES The basename and dirname commands are most commonly used in shell scripts where the commands are enclosed within back quotes (`). Enclosure within backquotes causes the command to be executed and the result substituted as an argument to another command. For example, if $1 is /users/tom/prog/mine.c, this sequence compiles /users/tom/prog/mine.c and moves the output to a file named mine in the current directory: cc $1 mv a.out `basename $1 '.c'` This sequence sets the Bourne shell variable NAME to /users/tom/prog: NAME=`dirname /users/tom/prog/mine.c` STATUS MESSAGES AND VALUES If string is only a slash, an error results and basename displays this message: January 1992 1



basename(1) basename(1)
expr: syntax error 0 FILES /bin/basename Executable file /bin/dirname Executable file SEE ALSO sh(1) 2 January 1992

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