Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    56

    Unanswered: Count # or occurences...

    I have the following file:

    4507DE58 0222075604 I H ent1 ETHERNET NETWORK RECOVERY MODE
    DED8E752 0222075604 T H ent1 ETHERNET DOWN
    4507DE58 0222075604 I H ent1 ETHERNET NETWORK RECOVERY MODE
    DED8E752 0222075604 T H ent1 ETHERNET DOWN
    4507DE58 0222075604 I H ent1 ETHERNET NETWORK RECOVERY MODE
    DED8E752 0222075404 T H ent1 ETHERNET DOWN
    BFE4C025 0222073404 P H sysplanar0 UNDETERMINED ERROR
    B6048838 0218154304 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED
    5DFED6F1 0218143004 I O SYSPFS UNABLE TO ALLOCATE SPACE IN FILE SYSTEM
    5DFED6F1 0218142404 I O SYSPFS UNABLE TO ALLOCATE SPACE IN FILE SYSTEM
    C092AFE4 0217154204 I O ctcasd ctcasd Daemon Started
    A6DF45AA 0217154204 I O RMCdaemon The daemon is started.
    2BFA76F6 0217153904 T S SYSPROC SYSTEM SHUTDOWN BY USER
    9DBCFDEE 0217154104 T O errdemon ERROR LOGGING TURNED ON
    192AC071 0217153804 T O errdemon ERROR LOGGING TURNED OFF
    B6048838 0210135704 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED
    C092AFE4 0206162604 I O ctcasd ctcasd Daemon Started
    A6DF45AA 0206162504 I O RMCdaemon The daemon is started.
    2BFA76F6 0206162204 T S SYSPROC SYSTEM SHUTDOWN BY USER
    9DBCFDEE 0206162404 T O errdemon ERROR LOGGING TURNED ON
    192AC071 0206162104 T O errdemon ERROR LOGGING TURNED OFF
    C092AFE4 0130155804 I O ctcasd ctcasd Daemon Started
    Now I need to create a counter that counts whenever colum 1 and 2 are the same for 2 lines.

    So I would need an output like:
    2 DED8E752 0222075604 T H ent1 ETHERNET DOWN

    Only those two colums need to be checked, but all fields and the counter must be returned.

    Any ideas?


    Thanx

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    Try this :

    Code:
    sort input_file | uniq -c
    The result for your example datas :
    1 192AC071 0206162104 T O errdemon ERROR LOGGING TURNED OFF
    1 192AC071 0217153804 T O errdemon ERROR LOGGING TURNED OFF
    1 2BFA76F6 0206162204 T S SYSPROC SYSTEM SHUTDOWN BY USER
    1 2BFA76F6 0217153904 T S SYSPROC SYSTEM SHUTDOWN BY USER
    3 4507DE58 0222075604 I H ent1 ETHERNET NETWORK RECOVERY MODE
    1 5DFED6F1 0218142404 I O SYSPFS UNABLE TO ALLOCATE SPACE IN FILE SYSTEM
    1 5DFED6F1 0218143004 I O SYSPFS UNABLE TO ALLOCATE SPACE IN FILE SYSTEM
    1 9DBCFDEE 0206162404 T O errdemon ERROR LOGGING TURNED ON
    1 9DBCFDEE 0217154104 T O errdemon ERROR LOGGING TURNED ON
    1 A6DF45AA 0206162504 I O RMCdaemon The daemon is started.
    1 A6DF45AA 0217154204 I O RMCdaemon The daemon is started.
    1 B6048838 0210135704 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED
    1 B6048838 0218154304 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED
    1 BFE4C025 0222073404 P H sysplanar0 UNDETERMINED ERROR
    1 C092AFE4 0130155804 I O ctcasd ctcasd Daemon Started
    1 C092AFE4 0206162604 I O ctcasd ctcasd Daemon Started
    1 C092AFE4 0217154204 I O ctcasd ctcasd Daemon Started
    1 DED8E752 0222075404 T H ent1 ETHERNET DOWN
    2 DED8E752 0222075604 T H ent1 ETHERNET DOWN
    Jean-Pierre.

  3. #3
    Join Date
    Dec 2003
    Posts
    56
    Originally posted by aigles
    Try this :

    Code:
    sort input_file | uniq -c
    Works like a charm! Thanx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •