Review your favorite Linux distribution.
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 01-10-2012, 06:20 PM   #1
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

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:

name var1
aaa xx
aaa gg
bbb yy
ddd zz

name var2
bbb mm
ccc nn
ddd pp
ddd qq


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
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

 man join
Old 01-10-2012, 07:03 PM   #3
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


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

All times are GMT -5. The time now is 08:34 AM.

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
Open Source Consulting | Domain Registration