Article 54ET3 Stop the running Command if a String Is found on stdout

Stop the running Command if a String Is found on stdout

by
blueray
from LinuxQuestions.org on (#54ET3)
How Can I close ping if a string is found in the output:

Code:$ ping google.com
PING google.com (74.125.130.138) 56(84) bytes of data.
64 bytes from sb-in-f138.1e100.net (74.125.130.138): icmp_seq=1 ttl=44 time=50.3 ms
64 bytes from sb-in-f138.1e100.net (74.125.130.138): icmp_seq=2 ttl=44 time=49.5 ms
64 bytes from sb-in-f138.1e100.net (74.125.130.138): icmp_seq=3 ttl=44 time=49.5 ms
64 bytes from sb-in-f138.1e100.net (74.125.130.138): icmp_seq=4 ttl=44 time=49.5 msNow I want something like:

Code:if ping google.com | grep -q 'time=49.5'; then
//terminate ping
fiSo that, if time=49.5 is there it will terminate ping command.latest?d=yIl2AUoC8zA latest?i=UvgQuiuaDQ4:03hENGAxroQ:F7zBnMy latest?i=UvgQuiuaDQ4:03hENGAxroQ:V_sGLiP latest?d=qj6IDK7rITs latest?i=UvgQuiuaDQ4:03hENGAxroQ:gIN9vFwUvgQuiuaDQ4
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