V10/man/man1/basename.1

Compare this file to the similar file:
Show the results in this format:

.TH BASENAME 1 
.CT 1 shell
.SH NAME
basename, dirname \- strip filename affixes
.SH SYNOPSIS
.B basename
.I string
[
.I suffix
]
.PP
.B dirname
.I string
.SH DESCRIPTION
These functions split off useful parts of a pathname;
they are typically used inside substitution marks
.BR `\ `
in shell scripts.
.PP
.I Basename
deletes any prefix ending in 
.L /
and the
.I suffix,
if present in
.I string,
from
.I string,
and prints the result on the standard output.
.PP
.I Dirname
places on standard output the name of the directory in which
a file named
.I string
would nominally be found.
The calculation is syntactic and independent of
the contents of the file system.
.SH EXAMPLES
.TP
.L
cc $1 -o `basename $1 .c`
Compile into 
.LR file ,
where
.L $1
is
.L file.c
or
.LR dir/file.c .
.TP
.L
cc $1 -o `dirname $1`/`basename $1 .c`
Compile 
.LR dir/file.c
into
.LR dir/file .
.SH "SEE ALSO"
.IR sh (1)