Warum ping -c 1 google.com | grep "bytes from" | cut -d = -f 1
gibt 64 bytes from 216.58.216.206: icmp_seq
zurück und nicht 0 ttl
? Ich erwarte, dass -f 1
zurück 0 ttl
.grep && awk Kombinationsergebnis in bash
0
A
Antwort
3
Sie können alles mit awk
bekommen und vermeiden grep
, cut
:
ping -c 1 google.com | awk -F= '/bytes from/{print $2}'
0 ttl
btw sollte Ihr Befehl sein:
ping -c 1 google.com | grep "bytes from" | cut -d = -f 2
die gleiche Leistung zu erhalten, wie 0 ttl
Feld # 2
1
ping -c 1 google.com | grep "bytes from" | cut -d = -f2
0 ttl
Wenn Sie bis 0 erhalten möchten ttl dann
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
@MonaJalal: Hat das für Sie funktioniert? – anubhava