perl scripting for deleting lines in a file

June 21, 2011 at 22:09:40
Specs: Linux i686
i want to delete lines in a file how can i delete a line by using perl scripting?plz help me

See More: perl scripting for deleting lines in a file

Report •

#1
June 22, 2011 at 07:07:01
http://answers.google.com/answers/t...

That's one of many hits on google. The script has to be modified to what you want.

How do you know when a politician is lying? His mouth is moving.


Report •

#2
June 22, 2011 at 10:37:59
This perl one-liner prints lines 12 to 17:

perl -wnl -e ' 12 <= $ . and $. <= 17 and print; ' datafile.txt

and this omits the first line:

perl -wnl -e ' $. › = 2 and print; ' datafile.txt


Report •

#3
June 22, 2011 at 11:28:02
# delete lines 3 and 6:

perl -wnl -e 'print if $. !~ m/^(3|6)$/' datafile.txt


Report •
Related Solutions


Ask Question