Displaying only data matching a pattern?
kenta
kenta at guster.net
Mon Feb 2 11:19:47 EST 2009
I've been working with some large files and need to extract a piece of
info, unfortunately there's a bunch of junk around the part that I
want. Example:
foofoo:A1234567890B\barbar
foofoo:C9234567890E\barbar
foofoo:A8234567890B\barbar
foofoo:F7234567890D\barbar
What I had done the first pass to get what I wanted was to use sed and
do a s/foofoo:// to get rid of the stuff in front, and then do the
same for the \barbar in the back. However what would be easier for me
is if I could just extract the pattern of [a-fA-F0-9] when they appear
n times in a row. I couldn't seem to figure out if sed could display
only the part I wanted. So I figured it'd be a better job for grep,
however It appears that it's printing the entire matching line and I
only want the match on the pattern to display.
Otherwise, I want as an end result:
A1234567890B
C9234567890E
A8234567890B
F7234567890D
Here's a caveat: I need to do this on a Windows box and am limited to
using the ports of GNU utilities (using
http://unxutils.sourceforge.net/) otherwise I'd do this in perl and
wouldn't be asking :/ I'm thinking maybe I'm just missing something
simple here.
Any quick solutions? My Google-fu is weak today.
-Kenta
More information about the gnhlug-discuss
mailing list