2007年6月5日星期二

basename -display file name component of path name

basename name [suffix]

从路径名中提取出文件名。
例如:basename /usr/bin/sort
Output "sort".

basename include/stdio.h .h
Output "stdio".

basename strips off the leading part of a path name, leaving only the
final component of the name, which is assumed to be the file name. To
accomplish this, basename first checks to see if name consists of
nothing but slash (/) or backslash (\) characters. If so, basename
replaces name with a single slash and the process is complete. If not,
basename removes any trailing slashes. If slashes still remain,
basename strips off all leading characters up to and including the
final slash. Finally, if you specify suffix and the remaining portion
of name contains a suffix which matches suffix, basename removes that
suffix.

basename /usr/bin/sort
Output "sort".
basename include/stdio.h .h
Output "stdio".

Possible exit status values are:
0
Successful completion.
1
Failure due to any of the following:
― unknown command line option
― incorrect number of arguments

没有评论: