1
ping website.com -n 3 | grep Minimum

会告诉你

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

我要添加什么来修剪除最小 ping 之外的所有内容?只让它输出“24”?

4

1 回答 1

1

您可以通过管道输出pinginto sed

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

或者,如果您有GNU grep,请输入:

grep -oP "(?<=Minimum = )[0-9]+(?=ms)"
于 2013-02-20T02:41:52.263 回答