How to parse the log file to get useful information using perl or shell?

Discussion in 'Perl Misc' started by robertchen117@gmail.com, Mar 26, 2007.

  1. Guest

    hi all,

    I have a very long log file like the below, how could I useful info I
    need like this:

    sr-204 Tec cache size:
    "ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
    total 1
    -rw-rw-rw- 1 0 0 54 Nov 01 23:53
    EventServer#opp1_0.dat

    Also is get every 3 lines just after every "Tec cache size" including
    the "Tec cache size" line.

    Or even could I get just include the host name and file size? Like
    this:
    sr-204 54
    sr-207 54
    ....

    The log file like this:

    .....
    =================
    sr-204.domain1.com:

    DISSE0155I Distribution ID: `1278500431.264831'

    ------------------------------
    STANDARD OUTPUT/ERROR BEGIN
    ------------------------------

    STANDARD OUTPUT (program: c:\temp\check_itm_cache\check_itm_cache.bat
    - exit code = 0)

    sr-204 Tec cache size:
    "ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
    total 1
    -rw-rw-rw- 1 0 0 54 Nov 01 23:53
    EventServer#opp1_0.dat
    ""

    ------------------------------
    STANDARD OUTPUT/ERROR END
    ------------------------------

    =================

    Software Package: "itm_cache^1.0"
    Operation: install
    Mode: not-transactional,not-undoable | force
    Time: 2007-03-25 22:02:58
    =================
    sr-207.domain1.com:

    DISSE0155I Distribution ID: `1278500431.264831'

    ------------------------------
    STANDARD OUTPUT/ERROR BEGIN
    ------------------------------
    STANDARD OUTPUT (program: c:\temp\check_itm_cache\check_itm_cache.bat
    - exit code = 0)

    sr-207 Tec cache size:
    "ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
    total 1
    -rw-rw-rw- 1 0 0 54 Nov 01 23:58
    EventServer#opp1_0.dat
    ""
    .....
     
    , Mar 26, 2007
    #1
    1. Advertising

  2. <> wrote:

    > I have a very long log file like the below, how could I useful info I
    > need like this:
    >
    > sr-204 Tec cache size:
    > "ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
    > total 1
    > -rw-rw-rw- 1 0 0 54 Nov 01 23:53
    > EventServer#opp1_0.dat



    ----------------------------------------------------
    #!/usr/bin/perl
    use warnings;
    use strict;

    local $/ = ''; # enable paragraph mode

    while ( <DATA> ) {
    next unless /Tec cache size/;
    print;
    }

    __DATA__
    =================
    sr-204.domain1.com:

    DISSE0155I Distribution ID: `1278500431.264831'

    ------------------------------
    STANDARD OUTPUT/ERROR BEGIN
    ------------------------------

    STANDARD OUTPUT (program: c:\temp\check_itm_cache\check_itm_cache.bat
    - exit code = 0)

    sr-204 Tec cache size:
    "ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
    total 1
    -rw-rw-rw- 1 0 0 54 Nov 01 23:53
    EventServer#opp1_0.dat
    ""

    ------------------------------
    STANDARD OUTPUT/ERROR END
    ------------------------------

    =================

    Software Package: "itm_cache^1.0"
    Operation: install
    Mode: not-transactional,not-undoable | force
    Time: 2007-03-25 22:02:58
    =================
    sr-207.domain1.com:

    DISSE0155I Distribution ID: `1278500431.264831'

    ------------------------------
    STANDARD OUTPUT/ERROR BEGIN
    ------------------------------
    STANDARD OUTPUT (program: c:\temp\check_itm_cache\check_itm_cache.bat
    - exit code = 0)

    sr-207 Tec cache size:
    "ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
    total 1
    -rw-rw-rw- 1 0 0 54 Nov 01 23:58
    EventServer#opp1_0.dat
    ""
    ----------------------------------------------------



    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Mar 26, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amratash
    Replies:
    0
    Views:
    560
    Amratash
    Apr 13, 2004
  2. subrato
    Replies:
    8
    Views:
    946
    Juan T. Llibre
    Mar 14, 2006
  3. unomystEz
    Replies:
    0
    Views:
    586
    unomystEz
    Nov 19, 2006
  4. Samuel A. Falvo II
    Replies:
    0
    Views:
    510
    Samuel A. Falvo II
    Oct 8, 2008
  5. Max Adams
    Replies:
    4
    Views:
    122
    Tad McClellan
    Aug 29, 2003
Loading...

Share This Page