Hey guys,
I'm having a bit of trouble getting this to work using either sed or grep. It's possible awk might be the ticket I need as well, but my regulat expression skills aren't quite up to the task for doing this.
I'm looking to grep for the string ERROR from the following log up until any instance of a space.
Here's an example of the log.
[24/Nov/2011:14:11:15] /root/bin/dbbackup.sh: started
[24/Nov/2011:14:11:15] 12591 > /var/run/dbbackup.pid
[24/Nov/2011:14:11:15] example.com started 1/3
[24/Nov/2011:14:11:15] example2.com started 2/3
[24/Nov/2011:14:11:15] ERROR: example2.com failed
mysqldump: Couldn't execute 'show create table `bbs`': Can't open file: 'bbs.ibd' (errno: 1) (1016)
mysqldump: Couldn't execute 'show create table `bbs`': Can't open file: 'bbs.ibd' (errno: 1) (1016)
[24/Nov/2011:14:11:15] example3.com started 3/3
[24/Nov/2011:14:11:15] ERROR: example3.com failed
mysqldump: Couldn't execute 'show create table `bbs`': Can't open file: 'bbs.ibd' (errno: 1) (1016)
mysqldump: Couldn't execute 'show create table `bbs`': Can't open file: 'bbs.ibd' (errno: 1) (1016)
[24/Nov/2011:14:11:58] /root/bin/dbbackup.sh: Finished after 0min and 43sec
If the grep was successful, my output would basically look like this:
[24/Nov/2011:14:11:15] ERROR: example2.com failed
mysqldump: Couldn't execute 'show create table `bbs`': Can't open file: 'bbs.ibd' (errno: 1) (1016)
mysqldump: Couldn't execute 'show create table `bbs`': Can't open file: 'bbs.ibd' (errno: 1) (1016)
[24/Nov/2011:14:11:15] ERROR: example3.com failed
mysqldump: Couldn't execute 'show create table `bbs`': Can't open file: 'bbs.ibd' (errno: 1) (1016)
mysqldump: Couldn't execute 'show create table `bbs`': Can't open file: 'bbs.ibd' (errno: 1) (1016)
Any help on this is appreciated. thanks!