5

sed script to parse logs issue

view full story
linux-howto

http://www.unix.com – I have this script to parse some logs: Code: #!/bin/bash id=$1 shift sed "/(id=$id)/,/^$/!d" "$@" Usage: ./script.sh 1234 logfile The logs have an empty line before the logged events/timestamps -- most of the time. And this is my issue, since when there is no empty line, it will catch things I don't want. An example of the logs: Code: test@server 2012-11-12 10:00:00 (id=1234) text text text test@server 2012-11-12 10:01:00 (id=1234) more text more text more text test@server 2012-11-12 10:02:00 (id=4321) even more text even more text eve (HowTos)