Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Token Statistics

Status
Not open for further replies.

cosmos77

Programmer
Oct 17, 2002
21
US
Hi,

i have a couple of text files with id numbers in a single column as follows:

File1
--------
v456
v567
v890
v345

and

File2
-------
v8907345
v2345873
v3678907


These are id's which i need to search in a bunch of Log files in a directory.

i need to make up a report if any of the id's in File1 or File2 are found in the LogFile then

Something similar to the following:-----

REPORT
-------------
LOGFILE NAME: (Where the ID was found)
ID:(Actual ID)
TYPE: FILE1/FILE2

is there a faster way to achieve this through AWK

Any help would be appreciated.

Thanks in Advance

Ajay







 
Cosmos:

If file1 and file2 aren't too large, how about reading the data into an array? The IDs are the index of the associative array. I'm matching the whole record of the data.file. That may not be correct.

Regards,

Ed



awk ' BEGIN {
while((getline < &quot;file1&quot;) > 0)
a[$1]=&quot;file1&quot;

while((getline < &quot;file2&quot;) > 0)
a[$1]=&quot;file2&quot;
}
{
for (i in a)
if(match($0, i))
{
printf(&quot;LOGFILE NAME: %s\n&quot;, FILENAME)
printf(&quot;ID: %s\n&quot;, i)
printf(&quot;TYPE: %s\n&quot;, a)
}

} ' d.file
 

Thanks a lot, Ed.... I get the idea.

Thanks Again
Ajay


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top