Aaron
Aaron

Reputation: 3325

trimming output of script

ping website.com -n 3 | grep Minimum

Will show you

Minimum = 24ms, Maximum = 62ms, Average = 36ms

What do I add to trim everything except the Minimum ping? To only make it output "24" ?

Upvotes: 1

Views: 72

Answers (1)

Steve
Steve

Reputation: 54502

You could pipe the output of ping into sed:

sed 's/Minimum = \([0-9]\+\)ms.*/\1/'

Or if you have GNU grep, pipe into:

grep -oP "(?<=Minimum = )[0-9]+(?=ms)"

Upvotes: 1

Related Questions