#!/bin/sh
result=$( grep 'packet loss' dummy |
awk '{ first=match($0,"[0-9]+%")
last=match($0," packet loss")
s=substr($0,first,last-first)
print s, last}' )
echo $result
----------------------
#there is a file named: dummy
#with the content: "There is 100% packet loss at node 1".
#possibly other lines
#note by wzy: first=11; last=15
Answer: 100%
No comments:
Post a Comment