I need a grep
command that finds all lines that only contain words with lengths greater than 10.
this is the grep
I wrote to find words bigger than 10 characters.
grep -E '(\w{11,})' input
How would I manipulate this command to include every word on the line?
Best Answer
Your condition might be more easily expressed in the contrapositive: instead of including lines where all words have length > 10, exclude those lines which have a word with length <= 10. Since grep supports both negation and word-matching, this could be written as, say:
-v
negates the match-w
means that the regex should match a whole wordAs Sundeep noted, we should use
{1,10}
to avoid matching the empty string (and thus every line).