Stripping lines from a file, a quick perl one liner

I’m getting bored of figuring this one out from first principles.

perl –n –e "if(!/^(SOMESTART|SOMEOTHERSTART)/) { print; }" filename.csv > smaller.csv

This is using the loop –n does, similar to the trick I’ve used with –p, it’s just that the –n doesn’t print automatically.  Instead I call print manually if a pattern is matched, or in this case, doesn’t match.

Advertisements