Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: What is the best way to remove(delete) specific lines from a very large file?

by fundflow (Chaplain)
on Dec 02, 2001 at 22:55 UTC ( #128996=note: print w/replies, xml ) Need Help??


in reply to What is the best way to remove(delete) specific lines from a very large file?

Just to add to the above suggestions (and more that will surely follow), it is most likely a job for grep:
cat big-file.txt | grep -v 'bad line' > new-file.txt

Or, alternatively:

perl -i.orig -pe '$_="" if /bad line/' big-file.txt

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://128996]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2021-05-07 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (91 votes). Check out past polls.

    Notices?