.TH basename "" "" Command
.PC "Strip path information from a file name"
\fBbasename \fIfile\fR [ \fIsuffix\fR ]
.PP
.B basename
strips its argument
.I file
of any leading directory prefixes.
If the result contains the optional
.I suffix,
.B basename
also strips it.
.B basename
prints
the result on the standard output.
.PP
For example, the command
.DM
	basename /usr/fred/source.c
.DE
.PP
returns
.DM
	source.c
.DE
.PP
.B basename
is most useful when it is used with other shell commands.
For example, the command
.DM
	for i in *.c
	do
		cp $i \(gabasename $i .c\(ga.backup
	done
.DE
.PP
copies every file that has the suffix \fB.c\fR into an identically
named file that has the suffix \fB.backup\fR.
.SH "See Also"
.Xr commands, commands
.Xr ksh, ksh
.Xr sh sh
