goodmis
1
I have 2 files that I need to combine.
One file is looks like this:
71664107;1;1;05-FEB-07;12-FEB-07;
The other file looks like this:
U;71664107;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;
I need to combine both files together. I need the shorter file added to the end of the longer file based on the common # 71664107.
I have tried using get line but sometimes it does not work.
Any suggestions?
sb008
2
Isn't all the information of the file with the short lines already in the file with the long lines?
U;71664107;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;
So you might be able to use:
nawk 'BEGIN { FS=";" } { print $0 $2";"$9";"$10";"$17";"$19";" }' <longfile>
goodmis
3
I have two files that I need to combine. The information is similar but 1 file is larger than the other. They must be combined.
Thanks
Ygor
4
If the files are sorted correctly, then try using join...
$ head file[12]
==> file1 <==
71664107;1;1;05-FEB-07;12-FEB-07;
==> file2 <==
U;71664107;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;
$ join -t ';' -1 2 -2 1 file2 file1
71664107;U;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;;1;1;05-FEB-07;12-FEB-07;
If they are in sorted format and lines matches. just use below command.
paste long_file short_file