Visit Our UNIX and Linux User Community


concatenate multiple file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting concatenate multiple file
# 1  
Old 07-26-2012
concatenate multiple file

Hi

Need some help to concatenate files

I have multiple spool files nearlly 15 of them which I need to concatenate like as shown in the below example
for ex.

file1.txt

Code:
aaaa|bbbbb|cccc|
dddd|eeee|ffff|
kkkkk|uuuuu|gggg|

file2.txt

Code:
xxxx|yyyy|zzzz|
1111||kkkk|lllll
rrrrr|3434|mmmm|

file3.txt

Code:
ooo|bbbbb|gggg|gggg|jjjjj|kkkkk|
wwww|tttttt|uuuuu|ppppp|qqqqq
zzzzz|vvvvv|ccccc|bbbbb|hhhhhh

o/p file

Code:
aaaa|bbbbb|cccc|xxxx|yyyy|zzzz|ooo|bbbbb|gggg|gggg|jjjjj|kkkkk|
dddd|eeee|ffff|1111||kkkk|llll|wwww|tttttt|uuuuu|ppppp|qqqqq
kkkkk|uuuuu|gggg|rrrrr|3434|mmmm|zzzzz|vvvvv|ccccc|bbbbb|hhhhhh

Thanks in Advance
Rashmi
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 07-26-2012 at 12:55 PM.. Reason: code tags, PLEASE
# 2  
Old 07-26-2012
Code:
#! /bin/bash
for x in {1..15}; do f="$f file${x}.txt"; done
paste -d'' $f

# 3  
Old 07-26-2012
Question paste command

what about something like?
Code:
paste file1 file2 file3


Previous Thread | Next Thread
Test Your Knowledge in Computers #388
Difficulty: Medium
The Unix make command uses A.I. to maintain, update, and regenerate related programs and files.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Concatenate column values when header is Matching from multiple files

there can be n number of columns but the number of columns and header name will remain same in all 3 files. Files are tab Delimited. a.txt Name 9/1 9/2 X 1 7 y 2 8 z 3 9 a 4 10 b 5 11 c 6 12 b.xt Name 9/1 9/2 X 13 19 y 14 20 z 15 21 a 16 22 b 17 23 c 18 24 c.txt Name 9/1 9/2... (14 Replies)
Discussion started by: Nina2910
14 Replies

2. Shell Programming and Scripting

Concatenate select lines from multiple files

I have about 6000 files of the following format (three simplified examples shown; actual files have variable numbers of columns, but the same number of lines). I would like to concatenate the ID (*Loc*) and data lines, but not the others, as shown below. The result would be one large file (or... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

3. Shell Programming and Scripting

Grouping multiple columns and concatenate

I have a CSV file that goes like this: Name,Group,Email Max,Group1,max@.com Dan,Group2,dan@.com Max,Group3,max@.com Max,Group4,max@.com Dan,Group5,dan@.com Jim,Group6,jim@.comBasically my desired output should be: Name,Group,Email Max,Group1|Group3|Group4,max@.com... (6 Replies)
Discussion started by: jeffreybsu
6 Replies

4. Shell Programming and Scripting

Concatenate columns from multiple files

Hi all, I want the 2nd column of every file in the directory in a single file with the file name as column header. $cat file1.txt a b c d e f $cat file2.txt f g h g h j $cat file3.txt a b d f g h (2 Replies)
Discussion started by: newbie83
2 Replies

5. Shell Programming and Scripting

Concatenate strings retrieved from a file and write it into another file

Hi, I have a file files.txt containing data as below: abc;xyz uvw;pqr 123;456 I want to develop strings like below using the above data and write them into another file: www/xxx/abc/yyy/xyz www/xxx/uvw/yyy/pqr www/xxx/123/yyy/456 All this needs to be done through .sh file. ... (4 Replies)
Discussion started by: archana.n
4 Replies

6. Shell Programming and Scripting

want to concatenate multiple files based on the rest of ls -lrt

uadm@4132> ls -lrt -rw------- 1 uadm uadm 3811819 Jun 6 04:08 data_log-2010.05.30-10:04:08.txt -rw------- 1 uadm uadm 716246 Jun 13 01:38 data_log-2010.06.06-10:04:08.txt -rw------- 1 uadm uadm 996 Jun 13 04:00 data_log-2010.06.06-10:04:22.txt -rw------- 1 uadm uadm 7471 Jun 20 02:03... (5 Replies)
Discussion started by: mail2sant
5 Replies

7. Shell Programming and Scripting

Concatenate multiple lines based.

Hello, I have been searching the forum for concatenation based on condition. I have been close enough but not got th exact one. infile: -----DB_Name ABC (X, Y,Z). DB_Name DEF (T). DB_Name GHI (U ,V,W). Desired Output file should be: ---------------------------DB_Name ABC... (8 Replies)
Discussion started by: indrajit_u
8 Replies

8. Shell Programming and Scripting

Find multiple patterns on multiple lines and concatenate output

I'm trying to parse COBOL code to combine variables into one string. I have two variable names that get literals moved into them and I'd like to use sed, awk, or similar to find these lines and combine the variables into the final component. These variable names are always VAR1 and VAR2. For... (8 Replies)
Discussion started by: wilg0005
8 Replies

9. Shell Programming and Scripting

Insert file names when concatenate files into a file

Hi I found the following line would concatenate all test_01 test_02 test_03 files into "bigfile". cat test_* >> bigfile But, what I'm looking for a way to insert each file names in order when concatenated in "bigfile". Thank you samky2005 (2 Replies)
Discussion started by: samky2005
2 Replies

10. UNIX for Dummies Questions & Answers

file Concatenate

Hi All, I have a question about file concatenate on unix. I have two file 1 of them like aaa,bbb,ccc,ddd other one is eee,fff,ggg,hhh I want to concatenate those file like this position aaa,bbb,ccc,ddd,eee,fff,ggg,hhh how can I do this ?? thanks. Alice (3 Replies)
Discussion started by: alisev
3 Replies

Featured Tech Videos