Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 7435  / 3 Years ago, mon, may 10, 2021, 1:44:41

In this line:



Reply from 10.11.12.13 time=1035ms



how to write an awk script which brings out just 1035.


More From » scripts

 Answers
2

You can use for example:



ping host | awk 'BEGIN {FS="[=]|[ ]"} {print $11}'


or, better to stop ping after sending one or more packets:



ping -c 1 host | awk 'BEGIN {FS="[=]|[ ]"} NR==2 {print $11}'


or



ping -c 5 host | awk 'BEGIN {FS="[=]|[ ]"} NR>=2&&NR<=6 {print $11}'





If you refer at this string: "Reply from 10.11.12.13 time=1035ms" and not at the output of ping command, you can use:



echo "Reply from 10.11.12.13 time=1035ms" | awk 'BEGIN {FS="[=]|ms"} {print $2}'

[#29638] Monday, May 10, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cugure

Total Points: 188
Total Questions: 110
Total Answers: 103

Location: Dominican Republic
Member since Sun, Sep 4, 2022
2 Years ago
;