Text-only | Table of Contents (frame/ no frame) |
(22) Manipulating Variables |
![]() ![]() ![]() |
${#var}
${var%pattern}
${var%%pattern}
${var#pattern}
${var##pattern}
$(( integer expression ))
datapath=/data/public/project/trials/set1/datafile.dat
filename=${datapath##*/}
filename
is set to "datafile.dat" since the longest prefix
pattern matching "*/" is the
leading directory path (compare basename
)
path=${datapath%/*}
path
is set to "/data/public/project/trials/set1" since the shortest suffix
pattern matching "/*" is the
filename in the last directory (compare dirname
)
i=$((i+1))
while
loops
variable-manipulation.src last modified Feb 11, 2005 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |