LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 04-27-2005, 12:11 PM   #1
doza
Member
 
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.

Thanks
 
Old 04-27-2005, 12:35 PM   #2
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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... ;-)

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

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
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.
 
  


Reply


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 12:16 PM
how to remove all commented lines win32sux Linux - General 11 05-08-2004 04:27 AM
remove identical lines in a file benjithegreat98 Linux - General 4 04-24-2004 07:12 AM
How do i remove blank lines from a file? kakho Programming 1 04-15-2004 04:57 AM
[bash] remove lines from a file Drimo Programming 3 03-20-2004 12:16 PM


All times are GMT -5. The time now is 11:12 PM.

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