On my system: CentOS 5
I can use \s
outside of collections but have to use [:space:]
inside of collections. In fact I can use [:space:]
only inside collections. So to match a single space using this I have to use [[:space:]]
Which is really strange.
echo a b cX | sed -r "s/(a\sb[[:space:]]c[^[:space:]])/Result: \1/"
Result: a b cX
\s
[[:space:]]
[^[:space:]]
These two will not work:
a[:space:]b instead use a\sb or a[[:space:]]b
a[^\s]b instead use a[^[:space:]]b