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!

Arrray print query

Status
Not open for further replies.

ranjit

Technical User
Apr 14, 2000
131
GB
I'm attempting to use a 2 file approach (as per CaKiwi) to get the desired results:

nawk -v file2 -f get.nawk file1

file2:
AB 100.00
AAC 120.00
DDEF 45.00
FER 199.10
GGP 599.00

file1:

AA Brand-1001
CC Brand-11233
DFD Brand-34022
fer Brand-239212
ggp Brand-394875

Desired Output:
FER Brand-239212 199.10
GGP Brand-394875 599.00


BEGIN {
if (!fn) fn="file2.dat"
while ((getline < fn) > 0) a[$1]=$2
close(fn)
}
{
print $0, a[$1]
}


Problem:
Occasionally When printing array items:

The $1 is in lowercase i.e print a[fer]

How can I "uppercase" field 1 entries in file1 such that print a[FER] works


Thanks,

 
Have you tried this ?
BEGIN {
if (!fn) fn="file2.dat"
while ((getline < fn) > 0) a[toupper($1)]=$2
close(fn)
}
{
print $0, a[toupper($1)]
}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top