To be more specific, it's the difference between
basic and
extended regular expressions.
grep and
sed use basic regex by default, and most of the more advanced regex devices like '
+' are not supported.
But gnu grep and sed also offer extended regex, which allows you to "activate" the special meanings of the characters by backslashing them. Perhaps a better way to do it, however, is to enable them globally with the use of "
grep -E" and "
sed -r". Then the behavior becomes reversed; the special meanings are enabled by default, and backslash escaping them makes them literal.
Code:
sed -r 's/^[ \t]+//' file
The grep man page goes into good detail about basic vs. extended regex.
Incidentally, if all you want to do is remove all instances of (a) certain character(s), you'll get better performance with
tr.
Code:
tr -d '[ \t]' <file