perl -ni -e 'print unless /pattern/' filename
Replace a matching pattern to another:
perl -pi -e "s/matchingpattern/newpattern/" filename
Remove duplicate lines:
perl -i -ne 'print unless $seen{$_}++' filename
Perl options:
-n: while (<>) { ... # your script}
-p: while (<>) { ... # your script } continue { print or die "-p destination: $!\n";}
-i: in place
No comments:
Post a Comment