Reputation: 8346
I able to do single grep but can not do OR search in unix solaris
Please see below examples i tried...
-bash-3.00$ echo "Hello hi" | grep -i "Hello"
Hello hi
-bash-3.00$ echo "Hello hi" | grep -i "Hello\|hi"
-bash-3.00$
Upvotes: 1
Views: 3586
Reputation: 41456
You can also use awk
for this:
echo "Hello hi" | awk '/Hello|Hi/'
Hello hi
Upvotes: 0
Reputation: 289755
You can make use of egrep
, which per definition is the same as grep -E
. It interprets the patterns as extended regular expressions, so that grep -E "hello|hi"
means: "grep either hello
or hi
".
So both of these should work:
echo "Hello hi" | egrep -i "hello|hi" # as you are using -i, no need to low/upper case
echo "Hello hi" | grep -Ei "hello|hi"
In case of doubt, you can always check your man grep
and see what they explain there. As I do not have access to any Solaris server, I cannot test myself.
Upvotes: 5