DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

basename(S)


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(C), dirname(S)

Examples

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

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

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005