You're viewing a comment by Unix User and its responses.
You're viewing a comment by Unix User and its responses.
I am being sponsored by Syntress since 2007! They bought me an amazing dedicated server to run catonmat on. If you're looking web services in Chicago area, I highly recommend the Syntress guys!
I love to read science books. They make my day and I get ideas for awesome blog posts, such as Busy Beaver, On Functors, Recursive Regular Expressions and many others.
Take a look at my
Amazon wish list, if you're curious about what I have planned reading next, and want to surprise me. :)


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!
Comment Responses
you can install gawk,and do like this:
Syntax:
gawk 'mathc($0,regex,array){print array[1]}' file
example:
gawk 'match($0, "https?:\/\/(.*?google.*?)/", array) {print array[1]}' filename
Reply To This Comment