Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

joining files with different rows and colum

UNIX for Dummies Questions & Answers


Tags
column, join, rows

 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-14-2009   -   Original Discussion by anjas
anjas's Unix or Linux Image
anjas anjas is offline
Registered User
 
Join Date: Mar 2009
Last Activity: 30 July 2012, 4:53 AM EDT
Location: Germany
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
joining files with different rows and colum

Hi all,

I have two files:

file one (9 rows, 3 columns):

A 1 x1
B 2 f1
C 3 f3
D 4 u5
E 5 l9
F 6 h6
G 7 g4
H 8 r4
I 9 s2

file two (4 rows, 1 column):

A
B
C
D

and I want output like this (4 rows, 3 columns):

file3:
A 1 x1
B 2 f1
C 3 f3
D 4 u5

Is there a way to do that, by using join or awk? When the rows are more than in those files, but still have 3 columns in file1 and 1 column in file2, how to do that? Tx
Sponsored Links
    #2  
Old Unix and Linux 05-14-2009   -   Original Discussion by anjas
ghostdog74's Unix or Linux Image
ghostdog74 ghostdog74 is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 28 January 2015, 8:30 AM EST
Posts: 2,669
Thanks: 0
Thanked 18 Times in 18 Posts
go look at the "More UNIX and Linux Forum Topics You Might Find Helpful" at the top of this page and see if any of them fits your bill
Sponsored Links
    #3  
Old Unix and Linux 05-23-2009   -   Original Discussion by anjas
Whiteboard's Unix or Linux Image
Whiteboard Whiteboard is offline
Registered User
 
Join Date: Feb 2009
Last Activity: 6 January 2011, 5:53 AM EST
Location: @........
Posts: 117
Thanks: 0
Thanked 0 Times in 0 Posts
I guess the below can help you out...



Code:
grep -f file2 file1

Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed or awk to convert text files with recurring headings to rows and colum Bjoeboo Shell Programming and Scripting 5 05-07-2008 10:47 AM
Joining 2 CSV files together chachabronson UNIX for Advanced & Expert Users 3 05-06-2008 06:42 AM
Help with joining two files rjlohman Shell Programming and Scripting 3 09-27-2006 11:55 AM
joining files Manu UNIX for Dummies Questions & Answers 2 04-25-2005 12:24 PM
joining 2 files webtekie UNIX for Dummies Questions & Answers 1 10-21-2003 10:51 AM



All times are GMT -4. The time now is 03:00 PM.