Hello everyone,
I have been struggling with the following situation, I think I am doing something wrong, can anyone help?
I have 2 comma separated files, the first is a look-up table that will supply the phone number based on the customer id, the second is a file containing customers and their id.
I would like to generate a file with customer name an phone number for each customer.
No matter what I try I do not seem to find proper matches. The code I have always runs into the 'not matched' section and generated the 'Error' string as printout for all of my incoming records.
When I will manage to see the matching occur then I will introduce the proper PRINT to gather all the data andl place that onto the output, for now I am just trying to see if I am actually able to match.
I also included the for loop at the end just to see I had populated the array properly .... everything to my eyes seems ok, yet I cannot get the matches to occur. Additionally can I also avoid the displaying of all the lines getting processed to go to the screen, I do not see which section of the code is doing that?
Hope someone can help.
Thanks in advance!
File uno contains:
000000030292,4121234567
000000031064,4121234444
000000031125,4122223474
File due contains:
000000030292,NAME1, LASTNAME1 ,OP ,TESTING1 ,OP ,FRI,10/29/2010,1100 ,FT,ENG
000000031064,NAME2, LASTNAME2 ,OP ,TESTING2 ,OP ,FRI,10/29/2010,1600 ,FT,ENG
000000031125,NAME3, LASTNAME3 ,OP ,TESTING3 ,OP ,FRI,10/29/2010,1500 ,FT,ENG
awk 'FS=","
FILENAME=="uno" {cd1[$1]=$2}
FILENAME=="due" {
if ( $1 in cd1)
{
print $0" Found" > "outtel"
}
else
{
print $1"Error" > "outtel"
}
} END {for (var in cd1){print var"---"cd1[var]"-" >"outtel"}}' due uno
This is the output I get in outtel:
000000030292Error
000000031064Error
000000031125Error
000000031125---4122223474-
000000031064---4121234444-
000000030292---4121234567-