I have this egrep command which's expression searchs for filenames with length 3 (excluding .extension):
ls | grep -E '^.{3}\.+'
However, I'm unable to write this with grep only, is it possible?
Try this:
ls | grep '^.\{3\}\.\+'
Basic vs Extended Regular Expressions
In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions \?, +, {, \|, (, and ).
(from man grep
)
(I can see that steeldriver beat me to it by some 30s while I was formulating the answer.)
grep
, why notls ???.*
?grep '^.\{3\}\.\+'
I think (i.e. escape the braces and the +)