[CentOS] how to separate individual logs?

John Doe jdmls at yahoo.com
Tue Nov 30 08:09:27 EST 2010


From: hadi motamedi <motamedi24 at gmail.com>

> On 11/30/10, John Doe <jdmls at yahoo.com> wrote:
> > The trick  is that your original file has '\r' chars lurking around...
> > Forgot I did  removed them manualy when I saw them...
> >   cat Edit3 | tr -d  "\r" | while read LINE; do
> > Instead of just copy/pasting, try to  understand what it does.
> > Here is how it works:
> >  - Read each  line in the LINE variable.
> >  - If the line contains the string  '>..', it is a "section" line.
> >    Set the log filename to  the section title.
> >  - If not, just write the line to the current  log filename.
> Sorry. I didn't get the point clearly.  What I need is to separate the
> log files from each of the modules. For  example, I need all of the log
> files coming from XAPP module. In the main  log, it can be
> distinguished by searching for the following line:
> XAPP  >..
> Then you see subsequent lines that are logs coming from this  module.
> Then the logs from another module will come following the  previous
> one.  I think you code is not doing this . Can you please correct me on
> my understanding of your code body?

My pseudo-code does exactly what you described (re-read it)...

And it creates <MODULE>.log files...
$ ll -n
total 36
-rw-r--r-- 1 2000 500 4678 nov 30 10:49 Edit3
-rw-r--r-- 1 2000 500   39 nov 30 10:54 HLR.log
-rw-r--r-- 1 2000 500 2320 nov 30 10:54 IPTR.log
-rw-r--r-- 1 2000 500  478 nov 30 10:54 SCCP.log
-rw-r--r-- 1 2000 500  754 nov 30 10:54 SNMP.log
-rw-r--r-- 1 2000 500  507 nov 30 10:54 TCAP.log
-rw-r--r-- 1 2000 500  281 nov 30 10:54 XAPP.log
-rwxr-xr-x 1 2000 500  207 nov 30 10:54 test.sh*

If you think it is not doing it, I cannot help you...
Either ask your sysadmin to help you, or use someone else code...

JD


      


More information about the CentOS mailing list