merging 2 files starting at the n'th line of the first file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting merging 2 files starting at the n'th line of the first file
# 1  
Old 05-30-2005
merging 2 files starting at the n'th line of the first file

Hi all,
I wonder if anyone could help me: I want to merge 3 files
together as shown below

I've seen the post adding columns from 01-05-2002, 09:23 AM
so know how to put 2 files together

basically I want to take output file of 1st merge and merge it with a 3rd file
but only start the merging at the n'th line of the file

so got output something like
line1 file1 line1 file2
line2 file1 line2 file2
line3 file1 line1 file3
line4 file1 line2 file3
line5 file1 line3 file3

for eample
file1:
2 3 0
6 2 0
2 3 1
5 3 1
6 9 1

file2
2 2 2
2 2 2

paste -d " " file1 file2 >"outputfile1"

outputfile1
2 3 0 2 2 2
6 2 0 2 2 2
2 3 1
5 3 1
6 9 1

now I want to merge in file3 from the 1st line with col3==0

file3
3 3 3
3 3 3
3 3 3

giving me outputfile2 to look like
outputfile1
2 3 0 2 2 2
6 2 0 2 2 2
2 3 1 3 3 3
5 3 1 3 3 3
6 9 1 3 3 3


Thanks a million for any suggestions offered
Best Regards,
Olga
# 2  
Old 05-30-2005
cat file2 file3 | paste -d ' ' file1 -
# 3  
Old 05-30-2005
Thanks !! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep file starting from pattern matching line

I have a file with a list of references towards the end and want to apply a grep for some string. text .... @unnumbered References @sp 1 @paragraphindent 0 2017. @strong{Chalenski, D.A.}; Wang, K.; Tatanova, Maria; Lopez, Jorge L.; Hatchell, P.; Dutta, P.; @strong{Small airgun... (1 Reply)
Discussion started by: kristinu
1 Replies

2. UNIX for Dummies Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g. File name: File.txt cat File.txt Result: #INBOUND_QUEUE=FAQ1 INBOUND_QUEUE=FAQ2 I want to get the value for one which is not commented out. Thanks, (3 Replies)
Discussion started by: Tanu
3 Replies

3. Shell Programming and Scripting

With script bash, read file line per line starting at the end

Hello, I'm works on Ubuntu server My goal : I would like to read file line per line, but i want to started at the end of file. Currently, I use instructions : while read line; do COMMAND done < /var/log/apache2/access.log But, the first line, i don't want this. The file is long... (5 Replies)
Discussion started by: Fuziion
5 Replies

4. Shell Programming and Scripting

How to read a file starting at certain line number?

I am new to ksh scripts. I would like to be able to read a file line by line from a certain line number. I have a specific line number saved in a variable, say $lineNumber. How can I start reading the file from the line number saved in $lineNumber? Thanks! (4 Replies)
Discussion started by: dcowboys13
4 Replies

5. UNIX for Advanced & Expert Users

Read file and skip the line starting with #

Hi all, I'm new in unix. Need some help here. I have a file called server.cfg which contains the servers name, if I don't want to run on that server, I'll put a "#" infront it. username1@hostname.com username2@hostname.com #username3@hostname.com #username4@hostname.com... (17 Replies)
Discussion started by: beezy
17 Replies

6. Shell Programming and Scripting

Merging two files with merging line by line

Hi, I have two files and i want to merge it like, file1.txt --------- abc cde efg file2.txt ------- 111 222 333 Output file should be, -------------- abc 111 (2 Replies)
Discussion started by: rbalaj16
2 Replies

7. Shell Programming and Scripting

Small Help required for merging two files per line!!!

Hi Guys, Sorry to bother everyone again here, but I ran into a small problem that has been after me for some time now. I have a file called file1.txt and has following content - /folder1/fold/folder 10k /folder167fold/folder 10MB /folder2/fold/folder 10G etc.. etc.. ... (1 Reply)
Discussion started by: rockf1bull
1 Replies

8. Shell Programming and Scripting

Grep from a starting line till the end of the file

Hi Folks, I got to know from this forums on how to grep from a particular line say line 6 awk 'NR==6 {print;exit}' But how do i grep from line 6 till the end of the file or command output. Thanks, (3 Replies)
Discussion started by: Mr. Zer0
3 Replies

9. Shell Programming and Scripting

merging similar columns in a single line file

Hi Guys. I have tried the commands sort and join. But I couldn't able to to find the command for joining in a single line based on keys.My example inputs and outputs are like the following. Help would be appreciated.:D Input file a1tabXXXXXXX a2tabXXXXXXX a6tabYYYYYYYYY a71tabXXXXXXX... (7 Replies)
Discussion started by: repinementer
7 Replies

10. Shell Programming and Scripting

Print starting 3rd line until end of the file.

Hi, I want to Print starting 3rd line until end of the file. Pls let me know the command. Thanks in advance. (1 Reply)
Discussion started by: smc3
1 Replies
Login or Register to Ask a Question