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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine two files

Status
Not open for further replies.

blarneyme

MIS
Jun 22, 2009
160
US
file 1:
/export/home/path1
host1 (variables)
host2 (variables)
host3 (variables)

/export/home/path2
host1 (variables)
host5 (variables)

/export/home/path3
host2 (variables)

file 2:
/export/home/path1
host2 (variables)
host3 (variables)
192.168.1.1 (variables)
10.0.0.1 (variables)

/export/home/path2
host1 (variables)

/export/home/path8
host7 (variables)

Desired:
/export/home/path1
host1 (variables)
host2 (variables) host2 (variables)
host3 (variables) host3 (variables)
192.168.1.1 (variables)
10.0.0.1 (variables)

/export/home/path2
host1 (variables)
host5 (variables)
host1 (variables)

/export/home/path3
host2 (variables)

/export/home/path8
host7 (variables)

I've tried something like this:
Code:
        NR==FNR {
                a[FNR]=$2
                c=FNR
                next
        }
        {
                for(i=1;i<=c;i++) {
                        print a[i],$3
                }
        }
but this isn't giving me what I want.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top