2016-05-19 8 views

答えて

3

あなたはawkを使用してそれをすべて取得し、grepを避けるため、cutことができます。

ping -c 1 google.com | awk -F= '/bytes from/{print $2}' 
0 ttl 

ところで、あなたのコマンドは次のようになります。

ping -c 1 google.com | grep "bytes from" | cut -d = -f 2 

0 ttlと同じ出力を得るためにフィールド#2

です
+0

@MonaJalal:これはあなたのために機能しましたか? – anubhava

1
ping -c 1 google.com | grep "bytes from" | cut -d = -f2 
0 ttl 

0まで取得したい場合ttl then

ping -c 1 google.com | grep "bytes from" | cut -d = -f1-2 
64 bytes from yyz08s14-in-f14.1e100.net (172.217.2.142): icmp_seq=0 ttl 
関連する問題