Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 04-27-2005, 11:11 AM   #1
Registered: Jan 2004
Distribution: Redhat
Posts: 31

Rep: Reputation: 15
How to remove lines from a file

I am trying to go through an apache log file that is fairly large. A lot of the entries in here are from Microsoft worms making the rounds. What is a quick way for me to remove those entries from the logs once they are already there? I've been using something like:

cat logfile | grep -v "worm_string" > cleanlogfile

There must be a faster way to do this. Maybe with sed and awk? Unfortunately I am not too proficient with those yet.

Any help is greatly appreciated.

Old 04-27-2005, 11:35 AM   #2
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 376Reputation: 376Reputation: 376Reputation: 376
just a thought: maybe you can speed it up a little bit by not using cat and instead using grep directly... it might save some cpu cycles at least... ;-)

grep -v "worm_string" logfile > cleanlogfile
Old 04-27-2005, 11:59 AM   #3
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
You might also look at the "logwatch" app (if you've installed it) and configure it to only send you the parts of the log(s) you want to see.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove odd lines from a text file Mr. Gone Programming 2 09-19-2005 11:16 AM
how to remove all commented lines win32sux Linux - General 11 05-08-2004 03:27 AM
remove identical lines in a file benjithegreat98 Linux - General 4 04-24-2004 06:12 AM
How do i remove blank lines from a file? kakho Programming 1 04-15-2004 03:57 AM
[bash] remove lines from a file Drimo Programming 3 03-20-2004 11:16 AM

All times are GMT -5. The time now is 03:53 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration