grep multiple words

Bash shell is the common linux command language.
Post Reply
mister_v
Posts: 177
Joined: Thu Mar 04, 2010 9:19 pm

grep multiple words

Post 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
chris
Site Admin
Posts: 180
Joined: Mon Jul 21, 2008 9:52 am

Re: grep multiple words

Post 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
Post Reply