Solved

Solaris 10 - Shell script

Posted on 2015-01-14
2
197 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

622 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