How to paste second file into the first file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to paste second file into the first file
# 1  
Old 10-12-2012
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
# 2  
Old 10-12-2012
you should interchange the filenames

Code:
 
paste -d "\t" file1 file2

# 3  
Old 10-12-2012
Why not just:
Code:
paste file1 file2

Guru.
# 4  
Old 10-12-2012
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create and paste two file into one

Hello i want to create this list: 2a05:b80:0:235::9f/1159 2a05:b80:0:235::a0/1160 2a05:b80:0:235::a1/1161 2a05:b80:0:235::a2/1162 2a05:b80:0:235::a3/1163 so write this shell as well: #Global VAR STR=159 END=200 #INI NET IPV6 PART SUM1=`expr $END - $STR` for ((i=STR;i<=END;++i)); do... (6 Replies)
Discussion started by: nimafire
6 Replies

2. Shell Programming and Scripting

How to cut a pipe delimited file and paste it with another file to form a comma separated outputfile

Hello ppl I have a requirement to split (cut in unix) a file (A.txt) which is a pipe delimited file into A1.txt and A2.txt Now I have to join (paste in unix) this A2.txt with external file A3.txt to form output file A4.txt which should be CSV (comma separated file) so that third party can... (25 Replies)
Discussion started by: etldev
25 Replies

3. Shell Programming and Scripting

Use of the PASTE command in a script file

Hi, When I use the paste command in the terminal window it works fine, but when i try to use it in a bash script file i get errors. I'm not sure how to use the paste command in a bash script file. my paste command looks like this paste <( code1 ) <(code2) thanks (7 Replies)
Discussion started by: eboye
7 Replies

4. OS X (Apple)

Paste text into vi file?

Hello, I'm running OS X 10.7.4. How can I paste text from the pasteboard into an open vim file? Thanks! (21 Replies)
Discussion started by: palex
21 Replies

5. Shell Programming and Scripting

Help required the cut the whole contents from one file and paste it into new file

Hi, First of all sincere apologies if I have posted in a wrong section ! Please correct me if I am wrong ! I am very new to UNIX scripting. Currently my problem is that I have a code file at the location /home/usr/workarea/GeneratedLogs.log :- Code :- (Feb 7, 571 7:07:29 AM),... (4 Replies)
Discussion started by: acidburn_007
4 Replies

6. Shell Programming and Scripting

How do you paste >> into a file in a terminal?

how do you paste >> into a file in a terminal? it keeps pasting as <<EOF EOF i just want it to show << i have a list of mysql commands in a text file and i want to paste it into another file which i'm using the terminal to edit thanks! (4 Replies)
Discussion started by: vanessafan99
4 Replies

7. Shell Programming and Scripting

awk read value from file and paste in other file

Hi, I'm working on a perl-awk loop combination and what I want to do is read in the first line of values.exp and pass that value to test1.exp; next, read in the second line of that file and pass that value to test2.exp. Which would mean: values.exp: 1.2 1.4 test1.exp 1 test2.exp... (10 Replies)
Discussion started by: tobias1234
10 Replies

8. Shell Programming and Scripting

Paste second columns from files to its corresponding file

Hi All, I have two sets of files. One set with extension .txt This set has file names with numbers like these. 1.txt, 2.txt, 3.txt until extactly 100.txt. The .txt files look like these: 0.38701788 93750 0.38622013 94456 0.38350296 94440 0.38282126 94057 0.38282126 94439 0.35847232... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

9. UNIX for Dummies Questions & Answers

Cut paste from one file to other

Hello, I am working on unix for the first time. I have to write a shell script where i want to cut paste from one file to other. File "1234.abc" is 03,12345555 16,936,x,x,120 16,936,x,x,100 49,12345555 03,12347710 16,936,x,x,115 16,936,x,x,122 49,12347710 03,12342222... (9 Replies)
Discussion started by: swapsb
9 Replies

10. Shell Programming and Scripting

Paste content of a file to another file and make it as columned

Pls help me on this. I have to 2 files like shown below: File 1 TAIJM AXPKIM BEMGW File 2 PXMPA JYGE IMJP What i want to do is to paste both file to a new file on thir format: File 3 TAIJM PXMPA AXPKIM JYGE BEMGW IMJP I tried cat and print, but it doesn't work. Cn... (6 Replies)
Discussion started by: kingpeejay
6 Replies
Login or Register to Ask a Question