Output of just the ping command:
[root@servera ~]# ping -c 4 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=8.04 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=7.47 ms 64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=7.72 ms 64 bytes from 8.8.8.8: icmp_seq=4 ttl=128 time=7.50 ms --- 8.8.8.8 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3007ms rtt min/avg/max/mdev = 7.473/7.683/8.037/0.225 ms I want to just capture the integer 4 from the "4 received".
ping -c 4 8.8.8.8 | awk -F ',' '/received/ { print $2 }'
The result is 4 received. I want to capture just the number 4 from the above command. How can I do that? The delimiter is space now.