06-06-06 06:27 AM
yezi wrote:
> Dear all:
>
> I try to code script to realize function which is described as after:
>
> I have tons of fles which is end with *.ping, try to parse out 2
> parameters from the last line of each file. The sentence is like as
> following :
>
> rtt min/avg/max/mdev = 136.200/136.643/137.152/0.612 ms, pipe 2
>
> The two paremeters are :
>
> 1> avg , which is 136.643
> 2> mdev, which is 0.612
To get only the lines you care about :
grep 'min/avg/max/dev' *.ping
To parse a value from each line, pipe the line into awk to get just
the series of numbers:
awk '{print $4}'
Then use cut to get only the one you care about :
cut -d/ -f2 (for avg)
cut -d/ -f4 (for mdev)
For example, to get the avg from all the files:
grep 'min/avg/max/dev' *.ping | awk '{print $4}' | cut -d/ -f2
Hope that helps.
- Logan
[ Post a follow-up to this message ]
|