'\"macro stdmacro
.if n .pH g3g.basename @(#)basename	40.6 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} basename 3G "" "\&"
.if \nX=1 .ds x} basename 3G ""
.if \nX=2 .ds x} basename 3G "" "\&"
.if \nX=3 .ds x} basename "" "" "\&"
.TH \*(x}
.SH "NAME"
\f4basename\f1 \- return the last element of a path name
.SH SYNOPSIS
\f4cc\f1
[\f2flag\fP \|.\|.\|.] \f2file\fP \|.\|.\|.
\f4\-lgen\f1
[\f2library\fP \|.\|.\|.]
.PP
\f4#include <libgen.h>\f1
.PP
\f4char \(**basename (char \(**path);\f1
.SH DESCRIPTION
Given a pointer to a null-terminated character string that contains
a path name,
\f4basename\fP
returns a pointer to the last element of \f2path\fP.
Trailing ``\f4/\fP'' characters are deleted.
.P
If
.I path
or
.I \(**path
is zero, pointer to a static constant ``\f4.\fP'' is returned.
.SH EXAMPLES
.TS
center ;
c c
lf4 lf4 .
Input string	Output pointer
_
/usr/lib	lib
/usr/	usr
/	/
.TE
.SH "SEE ALSO"
\f4dirname\fP(3G).
.br
\f4basename\fP(1) in the \f2User's Reference Manual\fP.
