| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 1: User Commands Oracle Solaris 11 Information Library |
- deliver portions of path names
/usr/bin/basenamestring [suffix]
/usr/xpg4/bin/basenamestring [suffix]
dirnamestring
Thebasename utility deletes any prefix ending in/ and thesuffix(if present instring) fromstring, and prints the result on thestandard output. It is normally used inside substitution marks (` `) within shellprocedures.
Thesuffix is a pattern defined on theexpr(1) manual page.
Thesuffix is a string with no special significance attached to any of the characters it contains.
Thedirname utility delivers all but the last level of the pathname instring.
Example 1 Setting environment variables
The following example, invoked with the argument/home/sms/personal/mail sets the environment variableNAME to the file namedmail and the environment variableMYMAILPATH tothe string/home/sms/personal:
example%NAME=`basename $HOME/personal/mail`example%MYMAILPATH=`dirname $HOME/personal/mail`
Example 2 Compiling a file and moving the output
This shell procedure, invoked with the argument/usr/src/bin/cat.c, compiles the named fileand moves the output tocat in the current directory:
example%cc $1example%mv a.out `basename $1 .c`
Seeenviron(5) for descriptions of the following environment variables that affect the execution ofbasename anddirname:LANG,LC_ALL,LC_CTYPE,LC_MESSAGES, andNLSPATH.
The following exit values are returned:
Successful completion.
An error occurred.
Seeattributes(5) for descriptions of the following attributes:
|
|
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |