I have a file like
$ cat num_range.txt
rate1, rate2, rate3, rate4, rate5
pay1, pay2, rate1, rate2, rate3, rate4
rev1, rev2
rate2, rate3, rate4
And I need to filter the comma-separated rows by matching against a prefix and a numeric range. For example - if the input is "rate" and range is 2 to 5, then I should get
rate2, rate3, rate4, rate5
rate2, rate3, rate4
rate2, rate3, rate4
If it is 5 to 10, then I should get
rate5
when I use perl -ne ' while ( /rate(\d)/g ) { print "$&," } ; print "\n" ' num_range.txt I get all the matches for the prefix,
But below one is not working.
perl -ne ' while ( /rate(\d){2,5}/g ) { print "$&," } ; print "\n" ' num_range.txt