concatenate two files with different No of rows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting concatenate two files with different No of rows
# 1  
Old 03-28-2009
concatenate two files with different No of rows

need a shell which perform following function

file 1 ( every time new data comes)

1212
2323
3434
4545
5656
.
.
.
.

file 2 (fixed line)

update bc_tbl set aix=data , bix=back where cix=U and serial=;

now when i execute shell it will concatinate file 1, file 2 & make file 3 as output

file 3

update bc_tbl set aix=data , bix=back where cix=U and serial=1212;
update bc_tbl set aix=data , bix=back where cix=U and serial=2323;
update bc_tbl set aix=data , bix=back where cix=U and serial=3434;
update bc_tbl set aix=data , bix=back where cix=U and serial=4545;
update bc_tbl set aix=data , bix=back where cix=U and serial=5656;

Thanks
# 2  
Old 03-28-2009
When you say the second file is fixed line, do you mean a single line in the file? because if it is the case, I don't really see what is the point for using a second file, you could just assign its content to a constant and use it in your script, no?.
# 3  
Old 03-28-2009
Something like this ?

Code:
$ for line in $(cat file1); do sed "s/;$/$line;/g" file2 ; done > file3

# 4  
Old 03-28-2009
try this
Code:
awk 'NR==FNR{tmp[NR]=$0}NR!=FNR{print tmp[FNR]$0}' static.txt dynamic.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenate rows and redefine range

I'm trying to find a way to concatenate consecutive rows (key is column $1 and $2) if column $5 an $6 are integers and redefine ranges in columns $3&$4 and $5&$6 Unfortunately I'm still learning the very basics so I cannot figure a way of doing this with awk. Input file 15 30 21 21 25.0... (11 Replies)
Discussion started by: alex2005
11 Replies

2. Shell Programming and Scripting

Concatenate broken rows

I need to concatenate the rows that are broken (because of carriage return and line feed) in unix. Input 123|456|789|"" 987|786|"GRT "|"" 3455|896|654|456|"" 457|234|"RT"|"PR TY"|"" Output 123|456|789|"" 987|786|"GRT"|"" 3455|896|654|456|"" 457|234|"RT"|"PRTY"|"" (16 Replies)
Discussion started by: meet_calramz
16 Replies

3. UNIX for Dummies Questions & Answers

Concatenate files and delete source files. Also have to add a comment.

- Concatenate files and delete source files. Also have to add a comment. - I need to concatenate 3 files which have the same characters in the beginning and have to remove those files and add a comment and the end. Example: cat REJ_FILE_ABC.txt REJ_FILE_XYZ.txt REJ_FILE_PQR.txt >... (0 Replies)
Discussion started by: eskay
0 Replies

4. Shell Programming and Scripting

Concatenate files

I have a file named "file1" which has the following data 10000 20000 30000 And I have a file named "file2" which has the following data ABC DEF XYZ My output should be 10000ABC 20000DEF (3 Replies)
Discussion started by: bobby1015
3 Replies

5. Shell Programming and Scripting

Need help to read rows from one file and concatenate to another

Hi guys; TBH I am an absolute novice, when it comes to scripting; I do have an idea of the basic commands... Here is my problem; I have a flatfile 'A' containing a single column with multiple rows. I have to create a script which will use 'A' as input and then output a string in in the... (6 Replies)
Discussion started by: carlos_anubis
6 Replies

6. UNIX for Dummies Questions & Answers

Read rows from source file and concatenate output

Hi guys; TBH I am an absolute novice, when it comes to scripting; I do have an idea of the basic commands... Here is my problem; I have a flatfile 'A' containing a single column with multiple rows. I have to create a script which will use 'A' as input and then output a string in in the... (0 Replies)
Discussion started by: carlos_anubis
0 Replies

7. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

8. Shell Programming and Scripting

Concatenate some of the rows...

i have a file as below and i need to load it into oracle. The problem is, some of the rows are in 2 lines. 123456_PosWlist ----- ----- IN 0/0 123456_PosWListRpt ----- ----- IN 0/0 123456_PosWListCSV ----- -----... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies

9. Shell Programming and Scripting

Concatenate rows in to 2 files

I have 2 files FILEA 1232342 1232342 2344767 4576823 2325642 FILEB 3472328 2347248 1237123 1232344 8787890 I want the output to go into a 3rd file and look like: FILEC 1232342 3472328 (1 Reply)
Discussion started by: unxusr123
1 Replies

10. Shell Programming and Scripting

Concatenate 2 rows into 1 row

I need to search a file for two values (valueA & valueB). ValueA will be on a different row than valueB, and concatenate the two together on the same row of my output. Example: search input file for strings "node" and "OS", combine the two results into one row input node A text text OS... (4 Replies)
Discussion started by: indianadoug
4 Replies
Login or Register to Ask a Question