madasafish
Technical User
Please advise on how to get nawk to print out the contents of the getline field:
Many Thanks,
Madasafish
rangefile:
hello world
myfile:
goodbye world
hello sir
Wanted result
hello sir|world
Code:
BEGIN {
while (getline < rangefile) {
catno[$1]=1;catno[$2]=$2
}
}
{
if (catno[$1])
{
#print $0 > "foundit"
print $0,catno[$2]"|"
}
}' myfile
Many Thanks,
Madasafish
rangefile:
hello world
myfile:
goodbye world
hello sir
Wanted result
hello sir|world
Code:
BEGIN {
while (getline < rangefile) {
catno[$1]=1;catno[$2]=$2
}
}
{
if (catno[$1])
{
#print $0 > "foundit"
print $0,catno[$2]"|"
}
}' myfile