[Project_owners] AWK related question

Atte Kemppilä atte.kemppila at iki.fi
Wed Aug 29 00:28:54 PDT 2007


On Wed August 29 2007 08:54, Michael Vincent van Rantwijk, MultiZilla wrote:
>
> I can do nice things with AWK these days, but the one thing I still
> don't get is how I should print the matching data of a search/regex like
> for example: /foobar/ { print } as in how do I get it to dump "foobar"
> (where foobar can be anything I need)?

Not quite sure that I understood the question but do you mean this:

$ echo 'foobar' | gawk '/o.*a/ { match($0, /(o.*a)/, arr); print arr[1] }'

With that you get 'ooba'. At least, in gawk.

http://groups.google.com/group/comp.lang.awk

-- 
Atte Kemppilä


More information about the Project_owners mailing list