LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   joining fileds from separete files (https://www.linuxquestions.org/questions/linux-newbie-8/joining-fileds-from-separete-files-490755/)

dominant 10-09-2006 02:42 AM

joining fileds from separete files
 
Hi

I want to join some fields from a file and some other fields from other files.

What if the first file lines are not the same as the second one?

slackie1000 10-09-2006 04:25 AM

hi there,
can you post an example of your files and what exactly you want to achieve?
regards,
slackie1000

dominant 10-09-2006 04:48 AM

Hi again

I did that join with the sdiff command.
Then, i manipulated the file by the vi and i fixed as i wish.

thanks for your response

Arjuna 10-21-2006 11:51 PM

Hi,

I am working with similar task. I have set of 8 files, that contain location data. One file is original, upon which all the others are based on. The files are different revisions of the same file, containing several additions (and perhaps also edits) to the original data. I need to merge these files into one, which contains all the original data and all the added lines, with all duplicate lines removed.

This is how it looks like:

Yuma;USA;Colorado;-102.832977777778;40.1329777777778;-7.0
Yupojin;Korea;Hambuk;129.0002;43.0110333333333;9.0
Zamora;Spain;;-5.7552;41.4990888888889;1.0
Zanesville;USA;Ohio;-82.0082555555556;39.9382555555555;-5.0
Zaragoza;Spain;;-0.8802;41.6568666666667;1.0
Zduny;Poland;Wielkopolska;17.3832555555556;51.6499222222222;1

I was trying to get the task done with sdiff:

Code:

sdiff -o locations.txt -s locations.dat locations1.dat
but I dont seem to get anything written in the outfile. When running the command, the differences are displayed and the sdiff endsi with % -prompt. Hitting enter gives a list of options. Selecting "e" for new version results in "0" being printed. I have tried all the listed options, but my outfile remains empty. I do not seem to figure out how do I create the outfile. Where am I lost?

Thanks.

Tinkster 10-22-2006 03:37 AM

How about a plain
cat file1 file2 file3 | sort -u > newfile


Cheers,
Tink

Arjuna 10-22-2006 01:01 PM

Oh thanks, that helped a lot! Good to learn about sort and uniq -commands! =)

In fact this is what I used:
cat *.dat > sort -u > locations.txt; cat locations.txt | sed s/,/./d | uniq -u > newfile2.txt

Still I see some characters are in latin-1 or latin-15, while others are in UTF-8. Wondering how do I correct that?

Lappeenranta;Finland;Etel�-Karjala;28.183333;61.066667;1.000000
Mets�hovi;Finland;;24.395556;60.216944;1.000000


All times are GMT -5. The time now is 07:10 AM.