LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-07-2010, 08:08 AM   #1
saurabhmehan
Member
 
Registered: Jul 2010
Posts: 44

Rep: Reputation: 0
Question Mapping with series from master file and calculate count


Hi All,



My shell script is calculating the count of each shortcode series wise whose sample output is as follows:

Code:
--------------------------
56882

9124 1
9172 1
9173 4
8923 6
9175 1
9058 2
7398 2
--------------------------
58585
series count
9124 1
8858 17
9061 21
9125 21
9126 7
9171 106
9172 4
7899 4
9173 7
9175 14
9059 92
7871 94
7396 183
7398 386
9060 13
--------------------------
58888
series count
9124 12
8858 2
9061 44
9125 36
9062 139
9171 20
9126 17
9172 94
9173 84
7899 113
8923 76
9175 59
9058 101
7870 327
7871 36
9059 24
7396 19
9122 202
7398 55
9060 62
--------------------------
57575
series count
8858 6
9124 6
9061 5
9062 26
9125 11
9171 5
9126 43
9172 14
9173 43
7899 7
9058 25
7870 15
8923 46
9175 71
7871 6
9059 13
7396 28
9122 17
7398 37
9060 15
--------------------------
57677
series count
9175 5


Code for generating above output is as follows:

Code:
Ydate=`date -d'-1 days' +'%Y-%m-%d'`
shortcodes=( "56882" "58585" "58888" "57575" "57677" );
for shortcode in ${shortcodes[@]}
do
        echo "--------------------------";
        echo $shortcode;
        echo "series count";
        grep "ShortCode=tel:${shortcode}" /opt/bea/ocsg_4.1/logs/customlogs/App_OP.log.$Ydate | awk -F"|" '{ arr[substr($2,1,4)]++ } END { for( no in arr) { print no , arr[no] } }'
done


And i have one master file whose data is as follows:

Code:
9059 North

7398 South

9175 North

9122 South

9175 North

7871 South


Now I want to map each series count with its Region mention in the master file and calculate the count region wise like following:

Code:
--------------------------
57677



North 5

South 0

--------------------------
57575

North 178
South 200

--------------------------
58888

North 123
South 109

Please help me in modifying my scipt for getting the above output

Thanks in advance.
 
Old 09-08-2010, 05:20 PM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
All your posts to LQ look like "Homework" to me

You are supposed to do this yourself, otherwise you'll never learn or graduate, or be employable.
 
  


Reply

Tags
asap


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Grep string from logs of last 1 hour on files of 2 different servers+calculate count saurabhmehan Linux - Newbie 6 09-06-2010 01:22 AM
Parse file from remote server to caculate count of string existence in that file saurabhmehan Linux - Newbie 2 08-30-2010 01:30 AM
how to delete last number/word of a file and incude file count at the end of the chennaiguy Linux - Newbie 2 02-18-2008 10:08 PM


All times are GMT -5. The time now is 06:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration