Friday, April 07, 2006
Output all the text from file Foo.txt except between “Chapter 2” and "Chapter 5"
Output all the text from file Foo.txt between “Chapter 2” and "Chapter 5"
Saturday, March 18, 2006
Monday, March 13, 2006
Sunday, February 12, 2006
${filename%.*} Extracting the filename by stripping off the file extension
$ FN="filename.jsp
$ echo ${FN%.*}
filename
$ echo ${FN%.*}
filename
${#string} Getting the length of a string
$ WORD=Supercalifragilisticexpialidocious
$ echo $WORD
Supercalifragilisticexpialidocious
$ echo ${#WORD}
34
$ echo $WORD
Supercalifragilisticexpialidocious
$ echo ${#WORD}
34
${var=default} If var is not set, set it to default
$ echo $username
null
$ echo ${username=`whoami`}
islandjoe
$ echo $username
islandjoe
null
$ echo ${username=`whoami`}
islandjoe
$ echo $username
islandjoe
${var-default} If var is not set, use a default
$ echo $username
null
$ echo ${username-`whoami`}
islandjoe
echo $username
null
null
$ echo ${username-`whoami`}
islandjoe
echo $username
null
Saturday, February 04, 2006
Friday, February 03, 2006
Special characters and operators
$var -Variable
${var} -Same as $var
${var-default} -If $var is not set, use the string "Morjens"
${var=default} -If $var is not set, set it to default and use that value.
${var+instead} - If $var is set, use instead. Otherwise empty string.
${var?message} -If $var is not set, print message. If $var is set, use its value.
${var} -Same as $var
${var-default} -If $var is not set, use the string "Morjens"
${var=default} -If $var is not set, set it to default and use that value.
${var+instead} - If $var is set, use instead. Otherwise empty string.
${var?message} -If $var is not set, print message. If $var is set, use its value.