in reply to One Liner, print multiple regex matches
perl -nle ' print "$1 $2" if /name=(\w+).*age=(\d+)/' filename
warnings can also be used with one-liners to help you debug:
perl -nlew ' print $1 $2 if /name=(\w+).*age=(\d+)/' filename Can't open print $1 $2 if /name=(\w+).*age=(\d+)/: No such file or di +rectory.
Please update your post to add "code" tags around your input file data.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: One Liner, print multiple regex matches
by cipher (Acolyte) on Nov 16, 2012 at 22:24 UTC |