Perl one-liner: deleting a line with pattern matching
Yes, it's the fact you're using single quotes. It means that $x
is being interpreted literally.
Of course, you're also doing it very inefficiently, because you're processing each file multiple times.
If you're looking to remove lines abc12
to abc17
you can do this all in one go:
perl -n -i.bak -e 'print unless m/abc1[234567]/' filename