How to paste second file into the first file | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Unix/Linux Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

How to paste second file into the first file

UNIX for Dummies Questions & Answers


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-12-2012
narachaid narachaid is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 28 October 2013, 1:09 PM EDT
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
How to paste second file into the first file

Hello,

I am new to Unix and hoping that someone could help me with this. I have 2 different text files that has more than 300,000 rows and would like to paste a single column on the File 2 as the very last column of File 1.

Example, File 1:

AAA DDD VVV RRR
AAA DDD VVV RRR
BBB HHH GGG SSS
QQQ ZZZ HHH RRR



File2:

TTT
TTT
TTT
TTT


What I want is:

AAA DDD VVV RRR TTT
AAA DDD VVV RRR TTT
BBB HHH GGG SSS TTT
QQQ ZZZ HHH RRR TTT


I tried to use:
paste -d "\t" file2 file1
but for some reason it got pasted as the first column instead of the last column.
Any help would be greatly appreciated! Thank you so much
Sponsored Links
    #2  
Old Unix and Linux 10-12-2012
itkamaraj's Unix or Linux Image
itkamaraj itkamaraj is offline Forum Advisor  
^Kamaraj^
 
Join Date: Apr 2010
Last Activity: 30 December 2014, 10:04 PM EST
Posts: 3,059
Thanks: 33
Thanked 659 Times in 638 Posts
you should interchange the filenames


Code:
 
paste -d "\t" file1 file2

Sponsored Links
    #3  
Old Unix and Linux 10-12-2012
guruprasadpr's Unix or Linux Image
guruprasadpr guruprasadpr is offline Forum Advisor  
Shrink...ing
 
Join Date: Jun 2009
Last Activity: 1 December 2014, 8:24 AM EST
Location: India
Posts: 676
Thanks: 30
Thanked 215 Times in 214 Posts
Why not just:

Code:
paste file1 file2

Guru.
    #4  
Old Unix and Linux 10-12-2012
narachaid narachaid is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 28 October 2013, 1:09 PM EDT
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Hello, Thank you for the responses.

I tried both of the codes and it gives me this:
(I am showing you a single line, just a very long sequence. File 1 is shown in blue and file 2 is shown in red)

June2012 57 928824 TACATCCGTAATATACATATATATATATATATATATATATATATGTATGAGTCGTGGAAGAACCAAATCATATTCACCACTACAGCACGTCGTAGCTAGT ATAGAATAAAGAGCTCAAAGAAAAAGGAACGTTATATATATGATCAGATTTCATGCTTATGTTCTACATATTATGGTTTTTCTATACTGACATTAACTGT ATTATACTATATATATTACACCGTGTTCACPos(+)CGGCCAGAATTAAGAAAC

I don't understand why the file 2 pasted in the middle of file 1, instead of separated by a tab after the very last column of file 1.
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Paste text into vi file? palex OS X (Apple) 21 10-29-2012 07:57 PM
Help required the cut the whole contents from one file and paste it into new file acidburn_007 Shell Programming and Scripting 4 06-13-2012 03:23 AM
awk read value from file and paste in other file tobias1234 Shell Programming and Scripting 10 04-18-2012 03:52 AM
Cut paste from one file to other swapsb UNIX for Dummies Questions & Answers 9 02-03-2011 02:08 AM
Paste content of a file to another file and make it as columned kingpeejay Shell Programming and Scripting 6 06-20-2009 05:40 PM



All times are GMT -4. The time now is 04:01 PM.