Diego Plentz
Diego Plentz

Reputation: 7190

how to combine 2 grep checks in a while loop

This is basically what I'm trying to do:

while string1 is not present in foo.log OR string2 is present in foo.log do
    echo .
loop

Examples of input files:

this should keep the while running

string1
foo
bar
string2

this should keep the while running

foo
bar

this should stop the while loop

foo
bar
string1

Upvotes: 0

Views: 148

Answers (1)

iruvar
iruvar

Reputation: 23364

"string1 is not present in foo.log OR string2 is present in foo.log" should translate to

while ! grep -q "string1" foo.log || grep -q "string2" foo.log; do
    echo .
done

Upvotes: 3

Related Questions