DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

basename(3G)


basename -- return the last element of a path name

Synopsis

   cc [flag . . . ] file . . . -lgen [library] . . .
   

#include <libgen.h>

char *basename(char *path);

Description

Given a pointer to a null-terminated character string that contains a path name, basename returns a pointer to the last element of path. Trailing ``/'' characters are deleted. If the string pointed to by path contains / only, basename returns a pointer to /.

If path or *path is zero, pointer to a static constant ``.'' is returned.

References

basename(1), dirname(3G)

Examples

Input string Output pointer
/usr/lib lib
/usr/ usr
/ /

 Input string   Output pointer
 /usr/lib       lib
 /usr/          usr
 /              /

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004