Extract data between two points in a text file
Ho开发者_开发问答w would it be possible to extract data between two points in a text file?
E.g.
Reply: [200/OK] bytes=29086 time=583ms
The value between "time=" and "ms"
sed -n 's/.*time=\(.*\)ms/\1/p' < logfile
This sets up a regular expression that captures everything between the time=
and ms
into the first capture group (which is referred to on the right-hand-side as \1
) and prints it.
cut -d= -f3 filename | grep -o '^[0-9]\+'
精彩评论