LinuxQuestions.org
Help answer threads with 0 replies.
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 01-10-2012, 06:20 PM   #1
newbie271
LQ Newbie
 
Registered: Jan 2012
Posts: 2

Rep: Reputation: Disabled
Question merge multiple files each with two columns. 11st col same but may have difft values


Hi
I have multiple files each with two columns and I need to combine all those file into a tab delimited file. (multiple entry with same name separated by a comma)

The content of the files are as follows:
---
file1.txt:

name var1
aaa xx
aaa gg
bbb yy
ddd zz
---
file2.txt

name var2
bbb mm
ccc nn
ddd pp
ddd qq
----

file3.txt

name var3
aaa uu
ddd vv
eee ww
fff tt
fff uu
---------

I need to combine all these file into a tab delimited file in such a way that the output looks like follows:

name var1 var2 var3
aaa xx,gg - uu
bbb yy mm -
ccc zz nn -
ddd - pp,qq vv
eee - - ww
fff - - tt,uu

I was wondering how to do this in unix. I can do the same in other language but because of efficiency issue I was looking to unix as a potential rescuer.

Thanks for ur help
 
Old 01-10-2012, 06:37 PM   #2
Janus_Hyperion
Member
 
Registered: Mar 2011
Location: /
Distribution: Fedora (typically latest release or development release)
Posts: 372

Rep: Reputation: Disabled
I think you should take a look at the command 'join'. The command 'paste' joins files column wise, but you want to remove the first column in all files except the first one. Take a look at

Code:
 man join
 
Old 01-10-2012, 07:03 PM   #3
newbie271
LQ Newbie
 
Registered: Jan 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
I looked earlier at join commands and it is extracting only those rows which are common between two files. However, I need to keep all unique rows in either files.
Thanks for reply
 
  


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
merge columns from multiple files vijay_babu1981 Linux - Newbie 21 06-24-2014 07:59 AM
[SOLVED] bash script: merge files comparing columns... masavini Programming 18 04-23-2011 06:01 AM
awk command to merge columns from two separate files into single file? johnpaulodonnell Linux - Newbie 4 01-23-2007 11:10 AM
Is there a command to merge two files as two columns of one file? davee Linux - General 2 07-19-2005 11:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:30 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration