How to extract part of string from all log files.?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to extract part of string from all log files.?
# 8  
Old 07-20-2016
Thanks a lot

---------- Post updated at 01:38 PM ---------- Previous update was at 06:29 AM ----------

Hi,

The below script is working fine

Code:
for filename in /home/log/*.log
do
tr -s '[,\]\[]' ' ' < $filename | 
     awk '
     {  if (index($0, "stats" ) > 0)
        {
         { for(i=1;i<=NF; i++)                               
             {               
                if( $(i) ~ /numberoffiles/ || $(i) ~ /numberofRows/ ) 
                {
                 printf("%s ", $(i) )
                }
             }
             printf("\n")
         }
       }
       if (index($0, "Time")> 0 )  
       {
         print $0
       } 
      
     } '  done > logs_output.txt

I want the table name also in the output

I want the output as below after stats : should be replaced with ,

Code:
Table abc.dat stats, numberoffiles=5, blocksize=100, numberofRows=3459

I hav tried
Code:
if (index($0, "Table" ) > 0)
{
print $0
}

It's printing complete thing

Code:
Table abc.dat stats: [numberoffiles=5, blocksize=100, numberofRows=3459, totalSize=4531,datasize=123]

Please help me

Thanks in Advance

---------- Post updated at 03:48 PM ---------- Previous update was at 01:38 PM ----------

Hi All,

Please help me.

Thanks

Last edited by ROCK_PLSQL; 07-20-2016 at 03:50 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need help to extract part of the string

Hi, I have a string with name as 20140412-s1-Potopolive_promos_20140412. So I want to extract only Potopolive string. Could you please help me the command. O/p : Potopolive Thx in advance (5 Replies)
Discussion started by: lkeswar
5 Replies

2. Shell Programming and Scripting

Unzip all the files with subdirectories present and append a part of string from the main .zip files

Hi frnds, My requirement is I have a zip file with name say eg: test_ABC_UH_ccde2a_awdeaea_20150422.zip within that there are subdirectories on each directory we again have .zip files and in that we have files like mama20150422.gz and so on. Iam in need of a bash script so that it unzips... (0 Replies)
Discussion started by: Ravi Kishore
0 Replies

3. Shell Programming and Scripting

Extract number part from the string in ksh 88

I have to extract number part (Date and timestamp part ) from the following 3 strings AB_XYZA_20130930183017.log AB_DY_XYZA_20130930183017.log AB_GZU_20130930183017.log Output should be 20130930183017 Please help me to get the string like above Thanks (2 Replies)
Discussion started by: smile689
2 Replies

4. Shell Programming and Scripting

Extract part of a string

I have a file with 100s of lines of text. I want to perform an extraction of this line: Info bpzs(pid=2652) using 1000 bits I have not been able to extract it. Should I try expr match or is there another method? This line has data both in front of and in back of it. I do not have grep -o... (5 Replies)
Discussion started by: newbie2010
5 Replies

5. Shell Programming and Scripting

extract part of string using sed

Hi, I have the following string and I need to extract the date from it: TextHere,2012/07/11,1 I tried using sed: sed -n 's#^.*\({4}/{2}/{2}\).*$#\1#p' But it doesn't return anything. The following line doesn't even return '2012': sed -n 's/^.*\({4}\).*$/\1/p' I used to use grep -o... (6 Replies)
Discussion started by: Subbeh
6 Replies

6. Shell Programming and Scripting

Get a part of a String from a log file

Hey there, I'm searched for one day your forum for a similar solution. Didn't find one, sorry :( Now here is what I'm searching for. I have the following multiple lines from a log (Edit: log name is SystemOut.log - this is not my day. I Apologize): 000042e2 1_BLA_Yab I logging.LogInfo... (5 Replies)
Discussion started by: nobodyhere
5 Replies

7. Shell Programming and Scripting

extract last part of string.

Hi, I have a string like this BUNDLE=/home/bob/flx/user.bun how to extract only the the last part ie, only user.bun (2 Replies)
Discussion started by: vprasads
2 Replies

8. Shell Programming and Scripting

get the part of log between 2 string

Hi Let's say I have a log file with this format: Marker1 End of Marker1 .... Marker1 End of Marker1 .... Marker1 End of Marker1 how to get the last part between End of Marker1 and Marker1? (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

9. Shell Programming and Scripting

How to extract certain part of log file?

Hi there, I'm having some problem with UNIX scripting (ksh), perhaps somebody can help me out? For example: ------------ Sample content of my log file (text file): -------------------------------------- File1: .... info_1 ... info_2 ... info_3 ... File2: .... info_1 ... info_2 ...... (10 Replies)
Discussion started by: superHonda123
10 Replies

10. Shell Programming and Scripting

Extract Part of string from 3rd field $3 using AWK

I'm executing "wc -lc" command in a c shell script to get record count and byte counts and writing them to a file. I get the result with the full pathname of the file. But I do not want the path name to be printed in the output file. I heard that using Awk we can get this but I don't have any... (4 Replies)
Discussion started by: stakuri
4 Replies
Login or Register to Ask a Question