Help cross-referencing files
Brad
brad at bradandkim.net
Mon Apr 18 13:46:32 CDT 2005
> 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
More information about the Kclug
mailing list