Solved

Solaris 10 - Shell script

Posted on 2015-01-14
2
180 Views
Last Modified: 2015-01-14
Hi,

I have a big text file (3G) that look like this:

150105 00:04:17                                                             ACTIVATE_SUBSCRIPTION                                                                                COMPLETE                                                                                                                  
150105 00:12:38                                                             ACTIVATE_SUBSCRIPTION                                                                                COMPLETE                                                                                                                  
150105 00:02:36                                                             ACTIVATE_SUBSCRIPTION                                                                                COMPLETE                                                                                                                  

You have in each line 3 columns: a timestamp, type and status.

As you can see in the time stamp part I have a date in the format as YEAR/MONTH/DAY.

What I need is a count for the total of lines I have for each type (in the example lines above is ACTIVATE_SUBSCRIPTION) and for every type a count for each status (in the example above is COMPLETE).

The possible types are:
ACTIVATE_SUBSCRIPTION
CHANGE_IMSI
CHANGE_MSISDN
DEACTIVATE_SUBSCRIPTION
DELETE_CARD
GET_REQUEST_INFORMATION
GET_SUBSCRIPTION_INFORMATION
PUSH_APPLICATIONS
PUSH_FILES
PUSH_FILE_PROFILE
REPUSH_FILES
SIM_SWAP
UPDATE_FEATURES
UPDATE_SUBSCRIPTION

And the possible statuses are:
QUEUED
ONGOING
COMPLETE
COMPLETE_WITH_ERRORS

The timestamp goes through 150105 to 150109.

So the output should look like this:
150105,ACTIVATE_SUBSCRIPTION,QUEUED,<the count of lines like this>
150105,ACTIVATE_SUBSCRIPTION,ONGOING,<the count of lines like this>
.
.
150105,SIM_SWAP,COMPLETE,<the count of lines like this>
.
.
150109,UPDATE_SUBSCRIPTION,COMPLETE_WITH_ERRORS,<the count of lines like this>

A sample of the file is attached.

Pls skip the first 5 lines of the file if possible...

Is this possible to be done?

Tks,
Joao
file-sample
0
Comment
Question by:joaotelles
2 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 total points
Comment Utility
If you have enough RAM, the easiest way is:

    awk 'NR > 5{print $1 "," $3 "," $4}' tstcom.txt | grep -v ',,' | sort | uniq -c

With your data (and 5 dummy lines added to the top, the output is:

    4 150105,ACTIVATE_SUBSCRIPTION,COMPLETE
   3 150109,UPDATE_SUBSCRIPTION,COMPLETE
   1 150109,UPDATE_SUBSCRIPTION,COMPLETE_WITH_ERRORS

If you want it swapped round so that the number is after the text, add

   | awk '{print $2 "," $1}'

to the end of the command line
0
 

Author Comment

by:joaotelles
Comment Utility
Tks worked just fine!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now