hplodur hplodur - 1 year ago 50
Perl Question

remove lines perl with multiple search patterns

I'm trying to find a way to use perl to remove lines that contain:


I've managed to find:

perl -pi -e "s,errors:,,"

Is there a way to specify all patterns that I'm looking for in one command?

Answer Source

Since you mention Perl you can use:

perl -ne 'print unless /errors:|mirror|raid\*|pond/'

Alternative you can use sed or grep:

sed '/errors:\|mirror\|raid\*\|pond/d'

Or grep with re-verse:

grep -v 'errors:\|mirror\|raid\*\|pond'

You can add the -inplace flag to both sed and Perl