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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mege and compare 3 files 7

Status
Not open for further replies.

mrr

Technical User
May 3, 2001
67
US
What is the best way to input 3 files into AWK?
I want to load each of the 3 files into different arrays and then gsub text and then compare/natch fields between the three files and then export to 1 merged file.

Can you do 3 while((getline<"file1,2,3) > 0) and load each file into an array?

Thanks
 
If I may, one last question:
I am trying to also print the string (s) result from the clean1 function and have edited the display function to be:

function display( id1, id2 ,id)
{ id = form_id( id1 ) "\t" form_id( id2 ) "\t"
printf "%s%s%s%s-%s-%s\n", id,
s,$0,substr($6,1,3),substr($5,1,3),substr($4,1,4)
}


Why do I not get the value of s to be printed for each record of all three files?

Thanks
 
not really following the code that closely, but......
where do you get an 's' [no pun intended] assigned to?

looking at the modified version o f'display' it looks like 's' is not a local variable. Therefore, it's assumed to be global. Looking at the rest of the code I don't see where 's' is defined/used as global.

Something is missing here.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
OK,
I see what I had to do, I changed the display function to:

function display( id1, id2 ,id)
{ id = form_id( id1 ) "\t" form_id( id2 ) "\t"
printf "%s%s%s%s-%s-%s\n", id,
clean1($1)"\t",$0,substr($6,1,3),substr($5,1,3),substr($4,1,4)
}

and it inserted the cleaned field one into output.

Thanks for everyones help, this is going to be a big help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top