LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-10-2008, 05:32 AM   #1
dwynter
Member
 
Registered: Jun 2002
Distribution: Centos 4.4
Posts: 82

Rep: Reputation: 15
How to find which file has a string when large number of files


Hi,

I have about 1000 files adding up to about 1GB in size. So performance is important. My knowledge is limited, just enough to get into trouble.

I tried running this in the current directory of the files

>for aFile in ls *.I; do awk '/aString/ { print $0 } $aFile; done;

Which I know only prints the line for where it is found, but wanted to start somewhere. But it just presents a prompt so clearly I do not understand something about the interaction between the for loop and awk.

Suggestions for the most efficient approach to achieving this?

Thanks,

David
 
Old 09-10-2008, 05:45 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
If you just want to print the names of the files which contain some string, this will be faster than using awk:
Code:
fgrep -l aString *.I

Last edited by matthewg42; 09-10-2008 at 07:46 AM. Reason: adding -l option
 
Old 09-10-2008, 07:06 AM   #3
dwynter
Member
 
Registered: Jun 2002
Distribution: Centos 4.4
Posts: 82

Original Poster
Rep: Reputation: 15
Thx, it is fast!
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming large number of files. checkmate3001 Linux - General 16 06-20-2009 12:16 PM
Syncing very large number of files to another server humbletech99 Linux - General 1 07-18-2008 08:58 AM
c: find out if a string represents a number? kpachopoulos Programming 2 08-15-2006 03:57 PM
Deleting a large number of files msteudel Linux - General 4 01-26-2005 02:36 AM
Large Number of files? mikeshn Linux - Security 2 01-10-2004 07:11 AM


All times are GMT -5. The time now is 08:25 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration