You're replying to a comment by Unix User.

Unix User Permalink
October 24, 2008, 00:20

Something I often need to do is match lines against a regexp, and print out a matching group within that line. But I have never been able to find a way to do this in awk, and end up resorting to Perl.

So - is there a way to do something like this?

/abc([0-9]+)def/ { print group(1); }

so that input of:

abc654def

produces:

654

Thanks!

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "lcd_100": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.