File Concatenation in a format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File Concatenation in a format
# 1  
Old 02-26-2014
File Concatenation in a format

I have some files named as:

error_abc.txt

error_def.txt

error_ghi.txt

I want to concatenate all these into a single file say error_all.txt. The error_all.txt should be displayed like:

Code:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
error_abc:

Errors of abc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
error_def:

Errors of DEF
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

error_ghi

Errors of GHI:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''''''


Thanks Smilie
# 2  
Old 02-26-2014
Try:
Code:
grep "" error_???.txt

# 3  
Old 02-26-2014
I mean the files which are concatenated into a single file should have their description and then the content separated by some symbol.

grep "" error_???.txt this is not working!!

---------- Post updated at 01:17 AM ---------- Previous update was at 01:12 AM ----------

@Scrutinizer:

Code:
grep "" error_???.txt

How to do this in multiple files?
# 4  
Old 02-26-2014
If mean:
Code:
grep "" file1 file2 file3 ... filen > allerrors_file

or
Code:
grep "" file* > allerrors_file

It is not exactly what you are looking for, but it may be close enough..
# 5  
Old 02-26-2014
It appends file names to the lines.
# 6  
Old 02-26-2014
Yes it prepends file names so that you know where the error messages originate from...
# 7  
Old 02-26-2014
head -n -0 file.txt file2.txt file3.txt > all.txt

this does the trick adds the header as the file name but no symbols.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Concatenation of multiple files based on file pattern

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies

2. Shell Programming and Scripting

Issue in Concatenation/Joining of lines in a dynamically generated file

Hi, I have a file containing many records delimited by pipe (|). Each record should contain 17 columnns/fields. there are some fields having fields less than 17.So i am extracting those records to a file using the below command awk 'BEGIN {FS="|"} NF !=17 {print}' feedfile.txt... (8 Replies)
Discussion started by: TomG
8 Replies

3. Shell Programming and Scripting

File concatenation

awk '{$2=$2":"$8"-"$3;$3=$NF;$4=$NF="";print $0 | $10=$10":"$8"-"$18;$11=$NF;$12=$NF="";print $0 }' design.txt Trying to concatenate specific fields in a spreadsheet and the others remain unchanged. I attached an excel spreadsheet (all the data comes from a design.txt), but I put an example... (3 Replies)
Discussion started by: cmccabe
3 Replies

4. Shell Programming and Scripting

Erroneous file concatenation.

I have more than one files in a directory , namely GLOW_OUT.txt FIELD_OUT.txt BASE_OUT.txt ... SHOW_OUT.txt What I wanted to do is to I am working in Korn Shell What I did was : for file in <directory_name>/*.* ;do cat $file | grep -v '^$' >> temp_file rm $file done ... (7 Replies)
Discussion started by: kumarjt
7 Replies

5. Shell Programming and Scripting

Converting windows format file to unix format using script

Hi, I am having couple of files which i used to copy from windows to Linux, so now in case of text files (CTRL^M) appears at end of line. I know i can convert this windows format file to unix format file by running dos2unix. My requirement here is that i want to do it automatically using a... (5 Replies)
Discussion started by: sarbjit
5 Replies

6. UNIX for Dummies Questions & Answers

To convert multi format file to a readable ascii format

Hi I have a file which has ascii , binary, binary decimal coded,decimal & hexadecimal data with lot of special characters (like öƒ.ƒ.„İİ¡Š·œƒ.„İİ¡Š· ) in it. I want to standardize the file into ASCII format & later use that as source . Can any one suggest a way a logic to convert such... (5 Replies)
Discussion started by: gaur.deepti
5 Replies

7. UNIX for Dummies Questions & Answers

Convert UTF8 Format file to ANSI format

:confused: Hi i am trying to convert a file which is in UTF8 format to ANSI format i tried to use the function ICONV but it is throwing error Function i used it as $ iconv -f UTF8 -t ANSI filename Error iam getting is NOT Supported UTF8 to ANSI please some help me out on... (9 Replies)
Discussion started by: rajreddy
9 Replies

8. UNIX for Advanced & Expert Users

Convert UTF8 Format file to ANSI format

:) Hi i am trying to convert a file which is in UTF8 format to ANSI format i tried to use the function ICONV but it is throwing error Function i used it as $ iconv -f UTF8 -t ANSI filename Error iam getting is NOT Supported UTF8 to ANSI please some help me out on this.........Let me... (1 Reply)
Discussion started by: rajreddy
1 Replies

9. UNIX for Dummies Questions & Answers

File Concatenation

Hi, I want to write a generic shell script, which can concatenate n number of files passed as parameter ;to an output file which is again a parameter Example catfl.sh outfl.txt a.txt b.txt c.txt (3 files to be concatenated into a file outfl.txt) catfl.sh outfl.txt a.txt b.txt(2 files to be... (3 Replies)
Discussion started by: samit_9999
3 Replies

10. Shell Programming and Scripting

File concatenation problem

I have written a script to find particular text files created within the last 24 hours and concatenate them all into a single concat.txt file. The problem that I am running into is that the last line of the text files do not terminate with <CR><LF> characters (as do all the other lines in each... (3 Replies)
Discussion started by: jvander
3 Replies
Login or Register to Ask a Question