Sponsored Content
Top Forums Shell Programming and Scripting Mapping with series from master file and calculate count Post 302451559 by poweroflinux on Tuesday 7th of September 2010 08:08:01 AM
Old 09-07-2010
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.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calculate the average of time series data using AWK

Hi, I have two time series data (below) merged into a file. t1 and t2 are in unit of second I want to calculate the average of V1 every second and count how many times "1" in V2 is occur within a second Input File: t1 V1 t2 V2 10.000000... (5 Replies)
Discussion started by: nica
5 Replies

2. Programming

Mapping all file at once or by page

This might be a silly question but I was wondering if, in case of huge files (2-3GB), it is more efficient to map the whole file at once, or to map it page by page. The file has to be processed sequentially from the start to the end. Thanks. (12 Replies)
Discussion started by: emitrax
12 Replies

3. Shell Programming and Scripting

Parse file from remote server to calculate count of string existence in that file

Hi I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files. Say a file abc.log exist on 2 servers. I want to search for string "test" on both files and calculate the total count of search string's existence. For... (6 Replies)
Discussion started by: poweroflinux
6 Replies

4. Shell Programming and Scripting

Grep string from logs of last 1 hour on files of 2 different servers and calculate count

Hi, I am trying to grep a particular string from the files of 2 different servers without copying and calculate the total count of its occurence on both files. File structure is same on both servers and for reference as follows: 27-Aug-2010... (4 Replies)
Discussion started by: poweroflinux
4 Replies

5. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

6. Shell Programming and Scripting

Creating unique mapping from multiple mapping

Hello, I do not know if this is the right title to use. I have a large dictionary database which has the following structure: where a b c d e are in English and p q r s t are in a target language., the two separated by the delimiter =. What I am looking for is a perl script which will take... (5 Replies)
Discussion started by: gimley
5 Replies

7. Shell Programming and Scripting

Search and replace with mapping from a mapper file in a target file

Hello, I have a special problem. I have a file in 8 bit and would like to convert the whole database to 16Bit unicode. The mapping file has the following structure: The mapper is provided as a zip file The target file to be converted contains data in English and 8 bit Urdu mapping, a... (4 Replies)
Discussion started by: gimley
4 Replies

8. UNIX Desktop Questions & Answers

How can I replicate master master and master master MySQL databse replication and HA?

I have an application desigend in PHP and MySQl running on apache web server that I is running on a Amazon EC2 server Centos. I want to implement the master-master and master slave replication and high availability disaster recovery on this application database. For this I have created two... (0 Replies)
Discussion started by: Palak Sharma
0 Replies

9. Shell Programming and Scripting

Replacing 12 columns of one file by second file based on mapping in third file

i have a real data prod file with 80+ fields containing 1k -2k records. i have to extract say 12 columns out of this which are sensitive fields along with one primary key say SEQ_ID (like DOB,account no, name, SEQ_ID, govtid etc) in a lookup file. i have to replace these sensitive fields in... (11 Replies)
Discussion started by: megh12
11 Replies
Chart::Clicker::Data::Series::HighLow(3pm)		User Contributed Perl Documentation		Chart::Clicker::Data::Series::HighLow(3pm)

NAME
Chart::Clicker::Data::Series::HighLow - Series data with additional attributes for High-Low charts VERSION
version 2.83 SYNOPSIS
use Chart::Clicker::Data::Series::HighLow; my @keys = (); my @values = (); my @highs = (); my @lows = (); my @opens = (); my $series = Chart::Clicker::Data::Series::HighLow->new({ keys => @keys, values => @values, highs => @highs, lows => @lows, opens => @opens }); DESCRIPTION
Chart::Clicker::Data::Series::HighLow is an extension of the Series class that provides storage for a three new variables called for use with the CandleStick renderer. The general idea is: --- <-- High | | - <-- max of Open, Value | | | | - <-- min of Open, Value | | --- <-- Low ATTRIBUTES
highs Set/Get the highs for this series. lows Set/Get the lows for this series. opens Set/Get the opens for this series. METHODS
add_to_highs Adds a high to this series. get_high ($index) Get a high by it's index. high_count Gets the count of sizes in this series. add_to_lows Adds a high to this series. get_low ($index) Get a low by it's index. low_count Gets the count of lows in this series. add_to_opens Adds an open to this series. get_open Get an open by it's index. open_count Gets the count of opens in this series. AUTHOR
Cory G Watson <gphat@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Cold Hard Code, LLC. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-22 Chart::Clicker::Data::Series::HighLow(3pm)
All times are GMT -4. The time now is 03:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy