Solved

Solaris 10 - Shell script

Posted on 2015-01-14
2
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 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

Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

752 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