Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Solaris 10 - Shell script

Posted on 2015-01-14
2
Medium Priority
?
209 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 20

Accepted Solution

by:
simon3270 earned 2000 total points
ID: 40549234
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
ID: 40549359
Tks worked just fine!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

885 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