LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-25-2008, 08:35 PM   #16
Clutch2
LQ Newbie
 
Registered: Feb 2008
Location: Northern Michigan
Distribution: Debian on Raspberry Pi's
Posts: 14

Original Poster
Rep: Reputation: 0

I found some thing that runs in under 30 seconds vs the 11 minute brute force straight grep.

$ find . -mtime 1 -print | xargs grep -i -C10 'SearchString'

Thanks to all,

Clutch
 
Old 02-25-2008, 09:10 PM   #17
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Btw, you might be able to speed this up some more by adding a -l flag
to grep instead of the context (which shouldn't help much with performance).
While this will only output the file-name rather than the match it will also
stop on the first match rather than carrying on to search the same file.



Cheers,
Tink
 
Old 02-26-2008, 03:35 AM   #18
Clutch2
LQ Newbie
 
Registered: Feb 2008
Location: Northern Michigan
Distribution: Debian on Raspberry Pi's
Posts: 14

Original Poster
Rep: Reputation: 0
Had time to learn one more thing, since I wanted to search the last 7 days of files I needed to use -7 for mtime or I only get 1 day of files feed to grep.

One day 7x24 hrs ago
$ find . -mtime 7 -print | xargs grep -i -C10 'SearchString'

All days since 7x24 hrs ago
$ find . -mtime -7 -print | xargs grep -i -C10 'SearchString'

Now I think I have it.

Clutch

Last edited by Clutch2; 02-26-2008 at 03:37 AM.
 
  


Reply

Tags
files, find, grep, recent



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't grep file ust Linux - Software 3 01-07-2008 06:03 AM
how to grep all users's certain file packets Linux - Newbie 5 01-03-2008 08:35 PM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 04:56 AM
Limiting the size of a log file ganninu Linux - General 1 09-18-2003 08:23 AM
grep file in the subdirectory juno Linux - General 3 09-30-2002 11:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:01 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
Open Source Consulting | Domain Registration