The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-05-2009
aemunathan aemunathan is offline
Registered User
  
 

Join Date: May 2008
Posts: 76
using awk to count no of records based on conditions

Hi

I am having files with date and time stamp as the folder names like 200906051400,200906051500,200906051600 .....hence everyday 24 files will be generated

i need to do certain things on this 24 files daily

file contains the data like

Code:
200906050016370   0   1244141195225298lessrv3       BSNLSERVICE1                  BSNLSERVICE1                  2128                                                        LOCATIONMANAGER          SLIR                 919443200299   MSISDN  ASC   919443200299   0   SUCCESS                                           1244141195225298less      919443200299        124414      79.301938811.6885305NORMAL    DELAY_                                                                                                                                                                                                                                                                                      WGS84  
200906050016440   0   1244141197503299lessrv3       BSNLSERVICE1                  BSNLSERVICE1                  2139                                                        LOCATIONMANAGER          SLIR                 919449838266   MSISDN  ASC   919449838266   0   SUCCESS                                           1244141197503299less      919449838266        124414      74.739722013.3302837NORMAL    DELAY_                                                                                                                                                                                                                                                                                      WGS84  
200906050017070   0   1244141224604306lessrv3       BSNLSERVICE1                  BSNLSERVICE1                  2128                                                        LOCATIONMANAGER          SLIR                 919448010097   MSISDN  ASC   919448010097   1   SYSTEM FAILURE                                    1244141224604306less      919448010097        124414                          NORMAL    DELAY_                                                                                                                                                                                                                                                                                      WGS84  
200906050017110   0   1244141227460308lessrv3       BSNLSERVICE1                  BSNLSERVICE1                  2128                                                        LOCATIONMANAGER          SLIR                 919449838266   MSISDN  ASC   919448010098   1   SYSTEM FAILURE                                    1244141227460308less      919449838266   124414                          NORMAL    DELAY_                                                                                                                                                                                                                                                                                      WGS84  

20090605140148        1204702370366140lessrv3                                     RTMS                          0                                                           TRACKING                 tlrep                                                            0   SUCCESS                                                                                         1                                                                                                                                                                                                                                                                                                                                     WGS84  
200906051402100   0   1195202147789210lessrv3       RTMS                          RTMS                                                                                      LOCATIONMANAGER          SLIR                 919446001620   MSISDN  ASC   919446001620   526 INACTIVE SUBSCRIBER                               1195202147789210less                          124419                          NORMAL    DELAY_                                                                                                                                                                                                                                                                                      WGS84  
200906051402100   0   1195202147789210lessrv3       RTMS                          RTMS                                                                                      LOCATIONMANAGER          SLIR                 919446001618   MSISDN  ASC   919446001618   526 INACTIVE SUBSCRIBER                               1195202147789210less                          124419                          NORMAL    DELAY_                                                                                                                                                                                                                                                                                      WGS84  
200906051402100   0   1195202147789210lessrv3       RTMS                          RTMS                                                                                      LOCATIONMANAGER          SLIR                 919446001617   MSISDN  ASC   919446001617   526 INACTIVE SUBSCRIBER                               1195202147789210less                          124419                          NORMAL    DELAY_                                                                                                                                                                                                                                                                                      WGS84


i need the scripts to do the following
1. It has to filter the records based on $4 and $6 (i.e $4==BSNLSERVICE1 AND $6==2128 ) and count the total records for the DAY (20090605*)


OUTPUT REQUIRED:
BSNLSERVICE1 2128 ==3


2. It has to filter the records based on $4 and $6 (i.e $4==BSNLSERVICE1 AND $6==2128) and count the total records for the DAY (20090605*) AND GROUP BASED ON $14 (i.e SUCCESS, FAILURE)


OUTPUT REQUIRED:
BSNLSERVICE1 2128 SUCCESS == 1
BSNLSERVICE1 2128 SYSTEM FAILURE ==2


3. It has to filter the records based on $4 and $6 (i.e $4==BSNLSERVICE1 AND $6==2128), GROUP BASED ON $9 (i.e 919448010098, 919446001618 ) and count the total records for the DAY (20090605*) FOR EACH DISTINCT $9


OUTPUT REQUIRED:
919449838266 2
919448010097 1


output should be of $4==BSNLSERVICE1 AND $6==2128 only ..other things ($4==RTMS) are not required.

Help me out pls

Last edited by aemunathan; 06-05-2009 at 09:33 AM..