How to remove lines matching a specific pattern in Perl?

I would like to do something similar to sedPerl, namely: delete lines matching a specific pattern.

Given this input:

abcd
edfd
abcd
derder
abcd
erre

I want to delete lines containing bc. How can i do this?

+5
source share
2 answers

I had to use double quotes on Windows: perl -ne "print if / bc /" file

+7
source

This is a FAQ.

How can I change, delete or insert a line in a file or add to the beginning of a file?

If you are programming in Perl, then it is worth spending a couple of hours to read the FAQ .

+3
source

All Articles