--- Brad brad@bradandkim.net wrote:
I'd use associative arrays in Perl or dicts in
Python. Trying to do
this in awk would be painful.
...
--
I had considered Perl, maybe I will give that another look. There is no way I know of to get this out of the IOS, but if someone can correct me on this please do.
How about: home:~$join file1 file2 > file2a home:~$join file2a file3 > file3a
syntax : join [options] <file1 name> <file2 name>
Or at least that used to be the syntax. It may have changed. 'Man join' or 'info coreutils join' should get you there. also you can specify which field is the match field for each file with options -1 and -2. Also, the files have to be sorted on the key field.
I know this may not be as exciting as writing an awk or shell script, but it should get the job done. And if you need to remove any columns from the final file "cut" should do the job.
So if you need to sort the files then match them and then cut fields out:
!/bin/bash # my file merger script sort -k12.14 vpifile > file1 sort -k1.14 ipfile > file2
join -1 2 -2 1 file1 file2 > file2a
sort -k16.9 file2a > file2b sort -k1.9 macfile > file3
join -1 1 -2 2 file3 file2a > file3a
cut 2 file3a > tadafile
#end
Of course you'll have to replace the values for filenames, keyfileds and such.
HTH, Brian D.
__________________________________ Do you Yahoo!? Plan great trips with Yahoo! Travel: Now over 17,000 guides! http://travel.yahoo.com/p-travelguide
How about: home:~$join file1 file2 > file2a home:~$join file2a file3 > file3a
syntax : join [options] <file1 name> <file2 name>
Or at least that used to be the syntax. It may have changed. 'Man join' or 'info coreutils join' should get you there. also you can specify which field is the match field for each file with options -1 and -2. Also, the files have to be sorted on the key field.
I know this may not be as exciting as writing an awk or shell script, but it should get the job done. And if you need to remove any columns from the final file "cut" should do the job.
So if you need to sort the files then match them and then cut fields out:
!/bin/bash # my file merger script sort -k12.14 vpifile > file1 sort -k1.14 ipfile > file2
join -1 2 -2 1 file1 file2 > file2a
sort -k16.9 file2a > file2b sort -k1.9 macfile > file3
join -1 1 -2 2 file3 file2a > file3a
cut 2 file3a > tadafile
#end
Of course you'll have to replace the values for filenames, keyfileds and such.
HTH, Brian D.
This looks like just what I need. I will research this more...thanks.
Brad