concat 3 files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting concat 3 files
# 1  
Old 09-20-2010
concat 3 files

Hello Unix gurus,
how to concat 3 files content side by side .
i have 3 files
Code:
more report1.txt
select *from tab1   A JOIN tab1    B ON
more report2.txt
A.PK1=B.PK1 where
more report3.txt
A.AAA <> B.AAA or
A.BBB <> B.BBB or
A.CCC<> B.CCCC or 
..
..
..
A.ZZZ <> B.ZZZ;

if i concatinate or append all three files it should give the output as
Code:
select *from tab1   A JOIN tab1    B ON
A.PK1=B.PK1 where
A.AAA <> B.AAA or
A.BBB <> B.BBB or
A.CCC<> B.CCCC or 
..
..
..
A.ZZZ <> B.ZZZ;(which is a valid SQL).

Can any one suggest how to approach this ?#

Last edited by Franklin52; 09-20-2010 at 08:54 AM.. Reason: Please use code tags!
kanakaraju
# 2  
Old 09-20-2010
Code:
cat report1.txt report2.txt report3.txt

# 3  
Old 09-20-2010
Yes worked.
Thanks

---------- Post updated at 06:51 AM ---------- Previous update was at 06:50 AM ----------

sed 's/.*/A.& <> B.& or/; $s/or$/;/'

using above sed in my script.

i have file report3.txt with content

more report3.txt

--------------------
AAAA
BBBB
CCCC
..
..
XXXX
YYYY
ZZZZ

26 record(s) selected.

when i use our sed command now the results is displazing 2 more lines in the begining and 1 more line extra in the bottom.Its reading the lines which are not required how to format that file ?

A. <> B. or
A. <> B. or
A.-------------------- <> B.-------------------- or
A.AAA <> B.AAA or
..
..
A.ZZZ <> B.ZZZ or
A. <> B. or
A. 26 record(s) selected. <> B. 26 record(s) selected. or
A. <> B. ;

I don't want the lines in red colour should be display in my output .any suggessions how to discard those line while printing?

kanakaraju
# 4  
Old 09-20-2010
Code:
awk '!(/^$/||/--/||/selected/){print "A." $1 " <> B." $1 " or"}' infile |sed '$ s/ or$/;/'

https://www.unix.com/shell-programmin...ut-file-2.html
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Concat data

All, I have 2 files A and B with some data. Now i want to concat data from both the files in to 3rd file.Please help me with a single command line. A--123456789 B--jlsjdfkajsjas output file C should be 123456789,jlsjdfkajsjas (2 Replies)
Discussion started by: kiranparsha
2 Replies

2. Shell Programming and Scripting

Concat name

Hi, I need help to combine the first 7 character of firstname if it is longer than 7and combine with the first character of lastname. ex: username lastname => usernaml user lastname => userl Thanks in advance. (10 Replies)
Discussion started by: xitrum
10 Replies

3. Shell Programming and Scripting

Concat required

Hi Folks The below is code is giving me value 30. cal | sed '/^$/d' | tail -1 | awk '{printf $NF-1}' Actually the text is like below. echo "you should reply on 30-Jan-2013 evening EST. Here how should i con-cat above logic in that text? (1 Reply)
Discussion started by: coolboy98699
1 Replies

4. Shell Programming and Scripting

Concat

Hi All, My Input file contains: Input.txt Name|Marks ABC|10 GHI|10 JKL|20 MNO|20 PQR|30 Output.txt MARKS|NAME 10|ABC,GHI 20|JKL,MNO 30|PQR Thanks in advance (4 Replies)
Discussion started by: kmsekhar
4 Replies

5. Web Development

Concat of two html files

By launching two SQL scripts I get two html files report_1.html and report_2.html with different background and text colors (white/blue for the former and silver/black for the latter) but if I try to concat the two html by using the CAT function on UNIX Server where Oracle is installed (cat... (2 Replies)
Discussion started by: Mark1970
2 Replies

6. Shell Programming and Scripting

concat 6 files in 1 file ( maybe use AWK?)

hi, I have the following problem: - 6 different files that have one key in common. - this six files must be aggregated in one output file sorted by the key. - the main file has to be writen twice, one in the beggining of the new output file and another in the end, for each key. - add one... (3 Replies)
Discussion started by: naoseionome
3 Replies

7. Shell Programming and Scripting

concat strings

Hello, I have a list of tablespaces in oracle and I want to concatenate 'drop tablespace' on the left of each line and 'INCLUDING CONTENTS AND DATAFILES' on the right of each line. Any idea how to do that? many thanks. PS: I tried to use excel and copy/paste it to vi. But I noticed many... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

8. Shell Programming and Scripting

concat fields

hi I have a file, I need to concatenate depening on the no of columns i need to concatenate. for example i need to concatenate field1,filed34,field2( no of columns is not always 3, it can be any number of fields) concat.ksh field1 field34 field2 how to achieve this, is there any argv ,argc... (10 Replies)
Discussion started by: markjason
10 Replies

9. Shell Programming and Scripting

Concat

HI all, How to concat two strings in Shell scrpits suppose x=a y=b i want to display it as ab How to do it ? Thanks.. (1 Reply)
Discussion started by: dhananjaysk
1 Replies

10. UNIX for Dummies Questions & Answers

Concat date

How do I concat a date to a filename eg; filename: jjjrtup to become jjjrtup29052002 mv jjjrtup jjjrtup ? date what should ? be (2 Replies)
Discussion started by: drukkie
2 Replies
Login or Register to Ask a Question