LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-09-2006, 03:42 AM   #1
dominant
Member
 
Registered: Jan 2004
Posts: 409

Rep: Reputation: 30
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?
 
Old 10-09-2006, 05:25 AM   #2
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 45
hi there,
can you post an example of your files and what exactly you want to achieve?
regards,
slackie1000
 
Old 10-09-2006, 05:48 AM   #3
dominant
Member
 
Registered: Jan 2004
Posts: 409

Original Poster
Rep: Reputation: 30
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
 
Old 10-22-2006, 12:51 AM   #4
Arjuna
LQ Newbie
 
Registered: May 2006
Posts: 11

Rep: Reputation: 0
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.
 
Old 10-22-2006, 04:37 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
How about a plain
cat file1 file2 file3 | sort -u > newfile


Cheers,
Tink
 
Old 10-22-2006, 02:01 PM   #6
Arjuna
LQ Newbie
 
Registered: May 2006
Posts: 11

Rep: Reputation: 0
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

Last edited by Arjuna; 10-22-2006 at 02:44 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
any command line software for ogg concatenation but ogmcat.? Joining ogg files Emmanuel_uk Linux - Software 1 06-15-2006 10:52 AM
Script: splitting lines in multiple files and joining them timmay9162 Programming 28 04-14-2006 09:52 AM
joining text files. chunky Programming 1 05-19-2004 11:42 AM
Joining *wmv files ? gazza Linux - Newbie 3 01-20-2004 01:48 PM
cat - joining files u02gtt Linux - Newbie 6 04-22-2002 09:49 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration