Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/utilities/b/basename.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/utilities/b/basename.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/utilities/b/basename.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/utilities/b/basename.html on line 8
Return the nondirectory portion of pathname (POSIX)
basename string [suffix]
Neutrino
- string
- A string of text.
- suffix
- A string of text.
The basename utility is useful primarily for extracting
the filename portion of a pathname, but since it performs only string
operations, you can use it with any string.
The basename utility prints to standard output a substring
of its string argument, plus a
newline character. The basename utility
forms this substring by doing the following, in order:
- Discarding any trailing slash (/) characters.
- Discarding all characters up to and including
the last slash character.
- Deleting the string argument's suffix, provided
you've specified a suffix operand that's identical
to the string operand's suffix.
If suffix is equal to the remaining string, the
suffix isn't removed (e.g. if suffix is
prog.c and the remaining string is
prog.c, the suffix .c isn't removed).
The result is a null string only if string is a
null string (""). In this case, basename outputs
a single newline character.
If string consists entirely of slash characters,
basename prints a single slash, followed by a
newline character.
You'll use the basename utility most often within
shell scripts, where it's normally invoked
inside back-ticks (`...`), or contained in
$(...).
Command: |
Output: |
basename . |
. |
basename /usr/src/prog.c |
prog.c |
basename /usr/src/prog.c .c |
prog |
basename /usr/src/prog.c .a |
prog.c |
basename /usr/src/ |
src |
basename ...//[fred] |
[fred] |
- 0
- Successful completion.
- >0
- An error occurred.
dirname,
fullpath
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/utilities/b/basename.html on line 174
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/utilities/b/basename.html on line 174