As you want to output the whole line there is really no need to capture anything with brackets. Just print the entire line if it ends with a nuber:
perl -ne 'print if /\d$/'print will print $_ by default /\d$/ will matche if $_ ends with a number (in good Perl golf spirit there is no need to use \d+ there: 1 digit is enough and we don't want to capture the number as we output the entire line).
An other slightly more cryptic way of writing it would be perl -ne '/\d$/ && print' but it's the same length, so no bonus point in Perl golf.
In reply to Re: regular expression
by mirod
in thread Matching lines in a file that end in numbers (was: regular expression)
by ashok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |