awk方法疑惑!请指点!!

awk方法疑惑!请指点!!

我现在一个问题,不知大家有没有注意,我的icmp_seq是不连续的,如下
代码:
[code:1]
64 bytes from 192.168.100.40: icmp_seq=1 ttl=64 time=0.043 ms
64 bytes from 192.168.100.40: icmp_seq=2 ttl=64 time=0.033 ms
64 bytes from 192.168.100.40: icmp_seq=3 ttl=64 time=0.034 ms
64 bytes from 192.168.100.40: icmp_seq=5 ttl=64 time=0.034 ms
64 bytes from 192.168.100.40: icmp_seq=6 ttl=64 time=0.032 ms
64 bytes from 192.168.100.40: icmp_seq=7 ttl=64 time=0.034 ms
64 bytes from 192.168.100.40: icmp_seq=9 ttl=64 time=0.034 ms
64 bytes from 192.168.100.40: icmp_seq=10 ttl=64 time=0.038 ms
64 bytes from 192.168.100.40: icmp_seq=11 ttl=64 time=0.038 ms
64 bytes from 192.168.100.40: icmp_seq=12 ttl=64 time=0.028 ms
[/code:1]
我现在想在icmp_seq=3这行与icmp_seq=5 中间加上一行 request timeout,在icmp_seq=7这行与icmp_seq=9 中间加上一行 request timeout然后仍然以4行一组输出,如下:
代码:
[code:1]
64 bytes from 192.168.100.40: icmp_seq=1 ttl=64 time=0.043 ms
64 bytes from 192.168.100.40: icmp_seq=2 ttl=64 time=0.033 ms
64 bytes from 192.168.100.40: icmp_seq=3 ttl=64 time=0.034 ms
request timeout

64 bytes from 192.168.100.40: icmp_seq=5 ttl=64 time=0.034 ms
64 bytes from 192.168.100.40: icmp_seq=6 ttl=64 time=0.032 ms
64 bytes from 192.168.100.40: icmp_seq=7 ttl=64 time=0.034 ms
request timeout

64 bytes from 192.168.100.40: icmp_seq=9 ttl=64 time=0.034 ms
64 bytes from 192.168.100.40: icmp_seq=10 ttl=64 time=0.038 ms
64 bytes from 192.168.100.40: icmp_seq=11 ttl=64 time=0.038 ms
64 bytes from 192.168.100.40: icmp_seq=12 ttl=64 time=0.028 ms
[/code:1]

再扩展一下,icmp_seq是顺序显示的,我的目的就是将icmp_seq这个值没有出来的行用request timeout来替代.而且四行一组,的表示出来.!请高手帮忙.(注:上面ping值不是全部,而只是一小部分),如下:
代码:
[code:1]
64 bytes from 192.168.100.40: icmp_seq=1 ttl=64 time=0.043 ms
64 bytes from 192.168.100.40: icmp_seq=2 ttl=64 time=0.033 ms
64 bytes from 192.168.100.40: icmp_seq=3 ttl=64 time=0.034 ms
request timeout

64 bytes from 192.168.100.40: icmp_seq=5 ttl=64 time=0.034 ms
64 bytes from 192.168.100.40: icmp_seq=6 ttl=64 time=0.032 ms
64 bytes from 192.168.100.40: icmp_seq=7 ttl=64 time=0.034 ms
request timeout

64 bytes from 192.168.100.40: icmp_seq=9 ttl=64 time=0.034 ms
64 bytes from 192.168.100.40: icmp_seq=10 ttl=64 time=0.038 ms
64 bytes from 192.168.100.40: icmp_seq=11 ttl=64 time=0.038 ms
64 bytes from 192.168.100.40: icmp_seq=12 ttl=64 time=0.028 ms

request timeout
request timeout
64 bytes from 192.168.100.40: icmp_seq=15 ttl=64 time=0.038 ms
64 bytes from 192.168.100.40: icmp_seq=16 ttl=64 time=0.028 ms

...
[/code:1]
请高手帮忙!!
只用单条命令我是搞不定,用shell脚本。不知道是否符合你大要求
[code:1]awk -F"=" 'BEGIN{i=1}{split($2,a," ");for(;i<a[1];){print "request timeout\n";i++}{print;i++}}'
[/code:1]
^_^还是要几个命令,有谁能用一句话搞定?
[code:1]sed -e '{
/icmp_seq=3/a\
request timeout
/icmp_seq=7/a\
request timeout
}'[/code:1]
大概就是这样的,可能具体的语法有点小问题。