add dirname(1), minor cleanups
[unix-history] / usr / src / usr.bin / basename / basename.1
.\" @(#)basename.1 6.2 (Berkeley) %G%
.\"
.TH BASENAME 1 ""
.AT 3
.SH NAME
basename, dirname \- strip filename affixes
.SH SYNOPSIS
\fBbasename\fP \fBstring\fP [ \fBsuffix\fP ]
.br
\fBdirname\fP \fBstring\fP
.SH DESCRIPTION
\fIBasename\fP deletes any prefix ending in `/' and the \fIsuffix\fP,
if present in \fIstring\fP, from \fIstring\fP, and prints the result
to the standard output. It is normally used inside substitution marks
(\`\`) in shell procedures.
.PP
\fIDirname\fP deletes from the last slash (``/'') to the end of
\fIstring\fP, and prints to result to the standard output.
.SH EXAMPLES
This shell procedure invoked with the argument \fI/usr/src/bin/cat.c\fP
compiles the named file and moves the output to \fIcat\fP in the current
directory:
.IP "" 15n
cc $1
.br
mv a.out \`basename $1 .c\`
.PP
The following line sets the shell variable \fIFOO\fP to \fI/usr/bin\fP.
.IP "" 15n
FOO=`dirname /usr/bin/trail`
.SH "SEE ALSO"
sh(1)