how to attach a variable from the 2nd file to the 1st file

Hi all,
I am a newbie in unix shell script world. Say, I have a list of devices in file01 and then also have file02 with the list of the location. I need to telnet to each devices in file01 and set the location according to file02. Example:
#cat file01
ttnpx01
ttnpx02
nncrd01
nncrd02
nkcrs01

#cat file02
liverpool
newtown
stockland
greenfield
newyork

With the for loop I can telnet to each device from file01, but I am not sure how to retrieve the variable from file02 and then attach to device. This is my basic script
#cat myscript
for host in `cat file01`
do
telnet $host
set location ...
done

Below is the result that I try to achieve:
ttnpx01 --> will have the location set to liverpool
ttnpx02 --> will have the location set to newtown
nncrd01 --> will have the location set to stockland
nncrd02 --> will have the location set to greenfield
nkcrs01 --> will have the location set to newyork

Can you please help? Thanks

One way:

awk 'NR==FNR{a[NR]=$0;next}{print a[FNR], $0}' file01 file02 |
while read host location
do
   echo $host 
   echo $location
   # do other stuff here
done

Regards

wow, thank you for your prompt respond. Your code looks good, I will check it then let you know the result. Again, thank you.

Hi Franklin52,
I have tried your code, it works fine with a linux machine. However, when I tried it with a SunOS, it failed due to the awk could not combine 2 files side by side. As a newbie I am still in learning process and have not much experiences with the awk, would you able to lend me a hand please?
Below is the result from the awk and I think it is not what you meant. Thanks
#awk 'NR==FNR{a[NR]=$0;next}{print a[FNR], $0}' file01 file02
ttnpx01
ttnpx02
nncrd01
nncrd02
nkcrs01
liverpool
newtown
stockland
greenfield
newyork

Try it with nawk.

Regards

Yes, it works with nawk. Thanks