Page 1 of 1

grep multiple words

Posted: Fri Aug 30, 2013 7:11 pm
by mister_v
Hi,

is there a way to use grep to check for more than 1 word?
Like both for left and right
grep right AND left

Re: grep multiple words

Posted: Sat Aug 31, 2013 1:16 pm
by chris
grep has an -E option (--extended-regexp)
This allows to us regular expressions.

Code: Select all

grep -E 'right|left' name_of_file.txt
You can check for more than 2:

Code: Select all

grep -E 'right|left|up|down' name_of_file.txt