script for taking the stats from a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script for taking the stats from a file
# 1  
Old 03-10-2009
script for taking the stats from a file

i have file which contains data like this every day.i need to pull up a report for counting the 203's in that file for each subscriber id.there are around 200 subscriber id's. all ths Y's which i have written in the script are the subscriber id's.could some one give me an idea as to how do it in a better way.

more 09031000010202.TL
203,0903100000042C,710,29,3,
207,0903100000042C,670,133,1
207,0903100000042C,26,9,7,09
207,0903100000042C,42,61,1,0
207,0903100000052C,710,29,7,
207,0903100000052C,50,7,7,09
207,0903100000052C,218,22,1,
207,0903100000052C,36,25,7,0
203,0903100000052C,720,24,3,
203,0903100000052C,36,79,3,0

Script:

#!/bin/sh
set -x
thisday =`date +%y%m%d00010202.TLG`

for Y in 2 144 9 129 16 37 42 45 87 104 53 40 62 63 51 158 18 19 20 21 50 67 82 116 64 100 141 168 170 171 49 84 85 35 34 70 61 69 8 26 27 28 78 79 32 33 10 11 130 25
36 47 57 200 173 6 46 48 55 56 72 118 22 13 110 109 203 29 80 12 660 222 696 664 666 669 670 671 672 674 675 676 677 39 207 208 209 210 211 212 680 681 682 43 683 59 6
84 103 659 205 91 689 690 692 30 215 216 217 218 697 698 700 52 174 705 706 707 220 708 710 711 712 713 714 715 716 717 718 719 720 721 722 23 31 724 219 77 88 17 66 7
30 83 68 120 96 5 667 678 679 685 186 15 726 733 728 731 732 734 221 736 94 95 97 99 41 74 65 105 738 98 38 73 7 4 739 44 740 112 113 114 14 3 1 24 54 81 58;
do
echo "$Y 203's = ";`cat $thisday | grep ^203 | grep "2C,$Y, | wc -l`; done
# 2  
Old 03-10-2009
That's complicated Smilie , this should work:
Code:
awk -F, 'NR==FNR{_[$0];next}$1==X && $3 in _{a++}END{print a}' X="203" subscriber.list `date +%y%m%d`00010202.TLG

# 3  
Old 03-10-2009
should i put this into a subscriber list file

2 144 9 129 16 37 42 45 87 104 53 40 62 63 51 158 18 19 20 21 50 67 82 116 64 100 141 168 170 171 49 84 85 35 34 70 61 69 8 26 27 28 78 79 32 33 10 11 130 25
36 47 57 200 173 6 46 48 55 56 72 118 22 13 110 109 203 29 80 12 660 222 696 664 666 669 670 671 672 674 675 676 677 39 207 208 209 210 211 212 680 681 682 43 683 59 6
84 103 659 205 91 689 690 692 30 215 216 217 218 697 698 700 52 174 705 706 707 220 708 710 711 712 713 714 715 716 717 718 719 720 721 722 23 31 724 219 77 88 17 66 7
30 83 68 120 96 5 667 678 679 685 186 15 726 733 728 731 732 734 221 736 94 95 97 99 41 74 65 105 738 98 38 73 7 4 739 44 740 112 113 114 14 3 1 24 54 81 58
# 4  
Old 03-10-2009
You should put each subscriber id on a separate line
Code:
2
144
9
etc.

# 5  
Old 03-11-2009
ins@ARTMGA01> awk -F, 'NR==FNR{_[$0];next}$1==X && $3 in _{a++}END{print a}' X="203" a.out `date +%y%m%d`00010202.TLG
333868
ins@ARTMGA01>

i get this when i run the above query i am not getting the count of 203's for each subscriber id
# 6  
Old 03-11-2009
subscriber id is the list above
# 7  
Old 03-11-2009
Code:
$ nawk -F, 'NR==FNR{_[$0]=0;next}$1==x && _[$3]!=""{a[$3]++}END{for(i in a){print i,a[i]}}' x=203 subscriber.list `date +%y%m%d`00010202.TLG
720 1
710 1
36 1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute Oracle gather stats via shell script

Hi , I am trying to automate a gather stats in shell script #!/usr/bin/ksh export ORACLE_HOME=/orcl/app/oracle/product/11.2.0.1/db_1 export PATH="$PATH:$ORACLE_HOME/bin" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$ORACLE_HOME/lib32" export TNS_ADMIN=/opt/netprobe/config... (1 Reply)
Discussion started by: neil.k
1 Replies

2. Shell Programming and Scripting

Taking error message from XML file, amending to script

Hello all, I have a question about creating a script that will look for messages on one of our MQ series systems, and fix them. Currently, if we issue a command for example Command.sh errors it gives us: ID:c3e2d840d4f3f3d74040404040404040cb2ef4e62f70f702 <?xml version="1.0"... (3 Replies)
Discussion started by: jeffs42885
3 Replies

3. Shell Programming and Scripting

Script taking more time in CRONTAB

Hello All, I have created a shell script, When i run it manually as ./<script_name> it takes 5 hours to run, but when i am scheduling it in crontab, it is taking 20 hours to run. Please help me and advice, what can be done to reduce the time in crontab. Thank you (6 Replies)
Discussion started by: anand2308
6 Replies

4. Shell Programming and Scripting

Script to load daily average I/O stats from a .ksh file into Oracle db

Hi can anyone help me with a script to load output of the .ksh file into an Oracle database. I have attached sample output of the information that i need to load to the database (2 Replies)
Discussion started by: LucyYani
2 Replies

5. Shell Programming and Scripting

How to ftp multiple files by taking the file name from a input file.

Hi, I'm working on a script which has to copy multiple files from one server to another server. The list of files that are to be copied is present in a file say input.txt. vi input.txt abc.c welcome.c new.c welcome1.c for ftp'ing a single file say 'new.c' the following code... (2 Replies)
Discussion started by: i.srini89
2 Replies

6. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

7. Shell Programming and Scripting

Perl script for taking inputs from one script and storing them into a document.

Hi. I wanted to create a Perl script which can take the outputs of a Perl script as it's input and temporarily store them in a document. Need help. Thanks.:) (8 Replies)
Discussion started by: xtatic
8 Replies

8. Shell Programming and Scripting

script to update the stats

Hi, I am using the below shell script to update the webalizer stats: #!/bin/bash username='elogic1' domain='abcd.com' path_to_webalizer='/hsphere/shared/bin/webalizer' path_to_logs='/hsphere/local/home/elogic1/logs/abcd.com'... (4 Replies)
Discussion started by: gsiva
4 Replies

9. Shell Programming and Scripting

Newbie to perl - Help with stats script

Hi, this is my first post so here goes..... I need help... I am trying to write a script to produce some stats based on a number of searches in a log file. Now i know how to do this using multiple variables which are really just greps, but I want a more efficent way of doing this as my poor... (1 Reply)
Discussion started by: ARwebble
1 Replies

10. Shell Programming and Scripting

script to gather weblogic jvm heap size stats

Hello, has anyone written something that will monitor/gather weblogic heap info ? I need to gather size, high/low stats to a file that I can upload to a speadsheet thanks for your help! (2 Replies)
Discussion started by: galenw
2 Replies
Login or Register to Ask a Question