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!

matching and replacing across two files

Status
Not open for further replies.

sumncguy

IS-IT--Management
May 22, 2006
118
US
A snip of the first exploration csv file results (actually : ) Ill call it data file 1.

Count:MgmntIP:Routerhostname:Model:Version:Flash Size:Free Flash:NVRam:DRAM:ConfReg:NextReg
19:10.200.159.233:atlanta:2610:12.0[14]:8388608:2692488:29688:27262976:2102:2102
20:10.200.159.241:veland:2610:12.0[14a]:8388608:2691744:29688:27262976:2102:2102
21:10.200.159.245:rclmilwaukeer1:2610:12.0[14a]:8388608:2691744:29688:27262976:2102:2102
22:10.200.20.4:smi1:WS-C4006:7.4[2]::::::
23:10.200.21.4:smi2:WS-C4006:7.6[2]::::::
24:10.200.23.132:sclsee1:C3500XL:12.0[5.3]WC(1):::32768:16777216:F:F
25:10.200.28.133:swi-7:C3500XL:12.0[5.4]WC(1):::32768:8388608:F:F
26:10.200.28.134:sm3:WS-C6506:6.3[5]::::::
27:10.200.28.197:smii-8:C3500XL:12.0[5.4]WC(1):::32768:8388608:F:F
28:10.200.28.198:swmii4:WS-C6506:6.3[5]::::::

There is missing data that I need to get by some other means. A snip of the second attempt to gather data. Note actual data shown above and below dont match. Just trying to illustrate what Im trying to do...
Ill call this one data file 2

MgmntIP:Flash Size:NVRam:DRAM:ConfReg
19:10.203.19.12:32768K:23717K:512K:524288K:0x2102
20:10.203.19.20:32768K:23717K:512K:524288K:0x2102
21:10.203.19.21:32768K:23717K:512K:524288K:0x2102
22:10.203.19.22:32768K:23717K:512K:524288K:0x2102
23:10.203.19.23:32768K:23717K:512K:524288K:0x2102
24:10.203.19.24:32768K:23717K:512K:524288K:0x2102
25:10.203.19.25:32768K:23717K:512K:524288K:0x2102
26:10.203.225.195:32K:32K:16384K/1024K:0xF
27:10.203.237.4:32K:32K:8192K/1024K:0xF
28:10.203.241.4:16384K:6489K:480K:65536K:0x2

In ksh, I want to match on ip and place the appropriate column from Data file 2 into Data file 1.
Thanks for the help.
SunOS xx 5.8 Generic_117350-28 sun4u sparcSUNW,Sun-Fire-V440
 
You may consider awk and its associative arrays fearure.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Also have a look at the join command. Note that the key fields to be joined (IP address in this case) need to be sorted for join to work properly.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top