I have this script to parse some logs:
#!/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:
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
even more text
Here my script would also return the events for id 4321, which I do not want.
Any great ides on how to solve this?