I have a text file that has the following format:
characters(that I want to keep) (space) characters(that I want to remove)
So for example:
I use egrep a lot to help "colorize" log lines, so I'm always looking for a new twist on regex. For me, the above works better by adding a \W like this:
$ egrep --color '^\S*\W|bag' /tmp/barf -o
foo
bag
hello
bag
keepthis
(etc.)
Problem is, my log files almost always are time-stamped, so I added a line to the example file:
2013-06-11 date stamped line
and then it doesn't work so well. So I reverted to my previous regex:
egrep --color '^\w*\b|bag' /tmp/barf
but the non-date-stamped lines revealed problems with that. It is hard to see this without colorization...