Download Shells: User's Guide
Transcript
Note
For the above four substitutions with the colon (:), if the colon
is omitted, the check for a null value is omitted.
$
$
x
$
19
x=""
echo ${x:- "x is null"}
is null
echo ${x- "x is null"}
$
${parameter #pattern }
${parameter ##pattern }
${parameter %pattern }
${parameter %%pattern }
If the Shell pattern matches the beginning of the value of
the parameter , substitute the value of the parameter with
the matching pattern removed; otherwise substitute the
value of this parameter . In the rst form the smallest
matching pattern is deleted and in the latter form the
largest matching pattern is deleted.
If the Shell pattern matches the end of the value of
parameter , then the value of parameter with the matched
part deleted is substituted; otherwise substitute the value
of parameter . In the rst form the smallest matching
pattern is deleted and in the latter form the largest
matching pattern is deleted.
These examples show how some of the parameter substitution techniques work.
To get the basename of a path:
d
$ prog=/users/mary/prog
$ basename=${prog##*/}
$ echo $basename
prog
$
a
As you can see in this example, the pattern /users/mary is matched and then
removed from the string.
19-8
Substitution Capabilities
Part III:
POSIX and Korn Shell
FINAL TRIM SIZE : 7.5 in x 9.0 in
Related documents
Shells: User's Guide
Sears 831.288264 User`s manual
Manual Supplement for HP Instrument BASIC Users Handbook
HP 720 Workstation Installation guide
EDMI Genius Register Manual
GPIB Programming Guide - Steven M. Anlage Research Page
HP 9000 742i Technical data
CAD-0215 Series User Manual v1.1_APT
USER`S MANUAL
English
HP GlancePlus User`s Manual
Notice - Agilent Technologies