On Mon, Feb 2, 2009 at 12:07 PM, kenta <ke...@guster.net> wrote: > > > Actually I need to get the info regardless of delimiters so matching > any hex digits of a certain length works for me. I'd sent an e-mail > before but I used the wrong address so maybe it didn't go through, for > som reason the gnu-port of grep for win32 has no -o option. :( >
You could try it this way in gawk: $ cat foo foofoo:A1234567890B\barbar foofoo:C9234567890E\barbar foofoo:A8234567890B\barbar foofoo:F7234567890D\barbar $ gawk --posix '{ if (match($0,/[[:xdigit:]]{12}/)) print substr($0,RSTART,RLENGTH) }' foo A1234567890B C9234567890E A8234567890B F7234567890D You need --posix for [:xdigit:] and the curly braces ( {} ) to work. This basically says: if the line ($0) matches 12 hexdigits ([:xdigit:]) in a row: print a substring of the line ($0) starting at RSTART and going for RLENGTH characters match() sets RSTART and RLENGTH for you on a match. -Shawn
_______________________________________________ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/