Article 54FRY Do actions based on if-else condition if a string Is found on stdout

Do actions based on if-else condition if a string Is found on stdout

by
blueray
from LinuxQuestions.org on (#54FRY)
@berndbausch has given a solution to stop the running command if a String Is found on stdout. Which is:

Code:ping google.com > /tmp/pingoogle &
PING=$!
while ! grep -q time=49.5 /tmp/pingoogle
do sleep 1
done
kill $PINGNow I want to run command based on condition.

For Example:

if icmp_seq=10 is found echo "10 pings"
if icmp_seq=20 is found echo "20 pings"
if icmp_seq=30 is found then kill $PING

Can anyone can help me do that?latest?d=yIl2AUoC8zA latest?i=-qatdH4hiT4:XWzPgT0Z6BE:F7zBnMy latest?i=-qatdH4hiT4:XWzPgT0Z6BE:V_sGLiP latest?d=qj6IDK7rITs latest?i=-qatdH4hiT4:XWzPgT0Z6BE:gIN9vFw-qatdH4hiT4
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments