[CentOS] how to separate individual logs?

John Doe jdmls at yahoo.com
Mon Nov 29 11:20:00 UTC 2010

From: hadi motamedi <motamedi24 at gmail.com>

> I have captured a file  in my centos showing logs captured from  many
> modules concurrently. Please find attached a sample of the file.  As
> you see, there are logs from individual modules that have been
> captured  concurrently. For example, there are logs from
> IPTR,SNMP,HLR,TCAP,XAPP,and  SCCP modules but they are coming
> concurrently.Each log has the header name of  its accompanied module in
> the beginning. I need to have the log of each  modules separately. Can
> you please show me the power of centos on how to  separate individual
> module's logs from the whole?

Here is "The Power of CentOS"!!!  (in approximately 3 minutes...)

cat edit.txt | while read LINE; do
  echo "$LINE" | grep -q '>\.\.'
  if [ $? -eq 0 ]; then
    LOGFILE=`echo $LINE | cut -d' ' -f1`.log
    echo "$LINE" >> $LOGFILE


PS: I wonder if I am doing your school homework...


More information about the CentOS mailing list