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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s