Reputation: 1
Hello I'm new to shell scripting and looking to use a terminal command with a while loop
and grep
for a certain phrase "TEST_PASS" or "Test_Skip" or "Test_Failed" in the output.
if the phrase "TEST_PASS" in the terminal output then exit the loop.
else if the phrase "Test_Skip" or "Test_Failed" is in the output then retry command again.
I thought it would go something like this:
while ! #Command# | grep -i "TEST_PASS"
any help would be great.
thanks much
Upvotes: 0
Views: 176
Reputation: 634
How about this?
<your command goes here> | grep -q "TEST_PASS"
retry=`echo $?`
while [ $retry -ne 0 ]
do
<your command goes here> | grep -q "TEST_PASS"
retry=`echo $?`
done
echo "Test Passed!"
Upvotes: 2