On Sat, Jan 26, 2013 at 3:13 PM, Mart Frauenlob
<address@hidden <mailto:address@hidden>> wrote:
Hello,
am I wrong if I think that an extglob pattern of i.e. !([[:digit:]])
should match all non-digit characters? Why don't they match in the
example below? Why are non-digit chars removed?
# cat extg
#!/bin/bash
shopt -s extglob
echo "address@hidden"
x=".:3:."
echo "Y${x}"
echo remove digits
echo "Y${x//@([[:digit:]])}"
echo remove non-digits
echo "Y${x//!([[:digit:]])}"
According to the bash manual, !(pattern-list) would match "anything
except one of the given patterns". But the matching is string based
rather than char based. So ${x//!([[:digit:]])} removed the string
".:3:." which does not match the pattern [[:digit:]].
More example:
$ shopt -s extglob
$ v=foobar
$ echo ${v//!(foo)/xxx}
xxx
$ echo ${v//!(bar)/xxx}
xxx
$