Remove lines beginning with a # using Perl

Following on from my tip the other day about using Notepad++ to remove certain lines, I thought I would follow up with a nice one liner you can do the same using Perl.

In this example you can see the before and after of the text file

MacBook-Air:~$ cat test.txt
#Hello
Goodbye
#Test
Test1
MacBook-Air:~ $ perl -i -nle 'print if !/#/' test.txt
MacBook-Air:~ $ cat test.txt
Goodbye
Test1

Nice and easy, hope this can help you out as well.  Do you have any more suggestions or tips like this, please get in contact or leave a comment below.

I am always interested in your thoughts so if you have any comments or feedback then please feel free to add any comments, or you can mail me  here.

Related Posts Plugin for WordPress, Blogger... 

 

Remove lines beginning with a # using bash

Identify and Delete all lines starting with # in Notepad++

Identify and Delete all lines starting with # in Notepad++