Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 30
joining fileds from separete files


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
Senior Member
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
hi there,
can you post an example of your files and what exactly you want to achieve?
Old 10-09-2006, 05:48 AM   #3
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
LQ Newbie
Registered: May 2006
Posts: 11

Rep: Reputation: 0

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:


I was trying to get the task done with sdiff:

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?

Old 10-22-2006, 04:37 AM   #5
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

Old 10-22-2006, 02:01 PM   #6
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?


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


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:18 PM.

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