Occasionally, you want to find all the lines in a file which have either 'eng', or 'net', or 'ide' in them.
You think "I know, I'll use regular expressions".
Now, you have three problems. The one you weren't expecting is grep's weird syntax for regular expressions.
This subject is both deep and boring. Suffice it to say that:
grep 'eng\|net\|ide'
is an answer
grep -E 'eng|net|ide'
and
ack 'eng|net|ide'
is an answer.
If you really want to know the details, look up 'basic regular expressions', 'extended regular expressions', and 'perl-compatible regular expressions'.
Monday, September 22, 2014
Subscribe to:
Post Comments (Atom)
Regular expressions are overkill for that purpose, since you can just use the -e parameter:
ReplyDeletegrep -e eng -e net -e ide
Also useful is the -f parameter if the patterns happen to be in a file
Regular expressions are overkill for that purpose, since you can just use the -e parameter:
ReplyDeletegrep -e eng -e net -e ide
Also useful is the -f parameter if the patterns happen to be in a file