LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Mapping with series from master file and calculate count (https://www.linuxquestions.org/questions/linux-newbie-8/mapping-with-series-from-master-file-and-calculate-count-830766/)

saurabhmehan 09-07-2010 07:08 AM

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.

tredegar 09-08-2010 04:20 PM

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.


All times are GMT -5. The time now is 05:20 AM.