On Thu, Sep 04, 2008 at 02:01:53PM -0500, David C. Rankin wrote:
Werner,
I have a question. Is the value=${value%%[[:blank:]]*} right? It looks like it is deleting everything in the parameter $value.
... normally the `*' in bash means not `match a sequence of 0 or more of the atom' but simply `Matches any string, including the null string'. Nevertheless bash 3.2.x understands the regular expression `[[:blank:]]' which is a space or a tab.
Testing yields:
if [[ $line =~ ^X-Mozilla-Status: ]] ; then echo -e "line = $line" value=${line#*:} echo -e "\tvalue=\${line#*:} = '$value'" value=${value%%[[:blank:]]*} echo -e "\t\${value%%[[:blank:]]*} = '$value'\n"
line = X-Mozilla-Status: 0009 value=${line#*:} = ' 0009' ${value%%[[:blank:]]*} = ''
Yes your're right the patterb matches all blanks followed by a string.
Shouldn't it be value=${value##[[:blank:]]} ? Doing this way yields the intended result:
line = X-Mozilla-Status: 0009 value=${line#*:} = ' 0009' ${value%%[[:blank:]]*} = '0009'
Also, couldn't we eliminate the second value expression altogether by including the [[:blank:]] in the first value expression like this:
value=${line#*:[[:blank:]]} which yields:
line = X-Mozilla-Status: 0009 value=${line#*:[[:blank:]]} = '0009'
Are there some gotchas in there? Just curious. Perhaps it was just slyly meant for additional learning....
learning means just doit ;) Werner -- "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org