merge txt question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting merge txt question
# 1  
Old 07-08-2008
merge txt question

time to ask the folks here

say I have two files, with each has 1 column, is there any way i merge these two files and put the column in file2 as column2 in the new merged file? how about I have 3 files and put the content in file2 as column2 and content in file3 as column3?

Thanks!

e.g.

file1

a
b
c
d
e
f

file2

1
2
3
4
45
5
6

filenew
a 1
b 2
c 3
d 4
e 45
f 5
.....
# 2  
Old 07-08-2008
Yes,
use the paste command:

Code:
paste -d\  file1 file2

# 3  
Old 07-08-2008
man paste...

e.g.
ant:/home/vbe/wks $ more 001
0
1
2
3
4
5
6
7
8
9
ant:/home/vbe/wks $ more 002
q
w
e
r
t
z
u
i
o
p
ant:/home/vbe/wks $ paste 001 002>003
ant:/home/vbe/wks $ more 003
0 q
1 w
2 e
3 r
4 t
5 z
6 u
7 i
8 o
9 p
003: END
# 4  
Old 07-08-2008
cool! I knew I would get my answer, thanks a lot! SmilieSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

2. Shell Programming and Scripting

To merge different sizes txt files

Hi, I have to .txt files that look like "baseMean" "log2FoldChange" "lfcSE" "stat" "pvalue" "padj" "c104215_g2_i4" 202.057864855455 5.74047973414006 1.14052672909697 5.03318299141063 4.8240223910525e-07 0.00234905721174879 "c91544_g1_i1" 373.123487095726 5.62496675850204 1.15060014539303... (2 Replies)
Discussion started by: alisrpp
2 Replies

3. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

4. UNIX for Dummies Questions & Answers

Need help combining txt files w/ multiple lines into csv single cell - also need data merge

:confused:Hello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux. I am working in Linux terminal. I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine... (2 Replies)
Discussion started by: jetsetter
2 Replies

5. Shell Programming and Scripting

Basic line reading and file merge question

No doubt these questions have been answered many times, but I struggled to find them - sorry. 2 questions: 1. I wish to read in a file one line at a time and do 'stuff' with it, such as: file="tst2" while IFS= read -r line do echo `wget -qO -... (3 Replies)
Discussion started by: Golpette
3 Replies

6. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

7. UNIX for Dummies Questions & Answers

find lines in file1.txt not found in file2.txt memory problem

I have a diff command that does what I want but when comparing large text/log files, it uses up all the memory I have (sometimes over 8gig of memory) diff file1.txt file2.txt | grep '^<'| awk '{$1="";print $0}' | sed 's/^ *//' Is there a better more efficient way to find the lines in one file... (5 Replies)
Discussion started by: raptor25
5 Replies

8. Shell Programming and Scripting

merge two two txt files into one file based on one column

Hi, I have file1.txt and file2.txt and would like to create file3.txt based on one column in UNIX Eg: file1.txt 17328756,0000786623.pdf,0000786623 20115537,0000793892.pdf,0000793892 file2.txt 12521_74_4.zip,0000786623.pdf 12521_15_5.zip,0000793892.pdf Desired Output ... (5 Replies)
Discussion started by: techmoris
5 Replies

9. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies

10. Solaris

Merge question

I'm applying patch 108993-65 and during the run it states" NOTICE: The following file is being changed by this patch: /etc/pam.conf A copy of the previous version has been saved under the name: /etc/pam.conf.pre108993-65 You must merge... (1 Reply)
Discussion started by: shorty
1 Replies
Login or Register to Ask a Question