![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Command to list large files | search66 | UNIX for Dummies Questions & Answers | 13 | 12-11-2008 08:20 AM |
| Searching a specific line in a large file | NIMISH AGARWAL | Shell Programming and Scripting | 4 | 07-10-2008 04:32 AM |
| Searching list of entries in file for actual files in dir | not4google | UNIX for Dummies Questions & Answers | 2 | 10-18-2006 11:24 AM |
| viewing and searching large file | Wrightman | UNIX for Dummies Questions & Answers | 1 | 04-29-2006 05:24 PM |
| List large files | GNMIKE | UNIX for Dummies Questions & Answers | 2 | 12-28-2005 01:48 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Searching for array in large list of files
I tried to make the title/subject detailed, but well.. have to keep it short as well.
I am wanting to take a large list of strings, and search through a large list of files to hopefully find numerous matches. I am not sure the quickest way to do this though. Code:
// List of files file1.txt file2.txt file3.txt file4.txt file5.txt file6.txt file7.txt // Searches testtag strings more stuff lots of stuff here Code:
find . -type f -size -100k | xargs egrep -il "(testtag|strings|more stuff|lots of stuff here)" ![]() |
|
||||
|
Code:
#!/usr/bin/perl
use strict;
sub find{
my($file,$str)=(@_);
open FH,"<$file";
$str=~s/,/|/g;
while(<FH>){
print "$file [line $.]: $_" if /($str)/;
}
print "---------------\n";
close FH;
}
my @arr=("a.txt","b.txt");
my $match="152178,014052";
map {find($_,$match)} @arr;
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|