There are several different regular expression syntaxes. The default value for grep is called the basic syntax in the grep documentation.
From human grep (1) :
In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions \?, \+, \{, \|, \(, and \).
Therefore, instead of +
you should have typed \+
:
grep '^[[:space:]]\+' FILE
If you need more energy from your regular expressions, I also recommend that you take a look at the Perl regular expression syntax. They are generally considered the most expressive. There is a C library called PCRE that mimics them, and grep links to it. To use them (instead of the basic syntax), you can use grep -P .
source share