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
# 15  
Old 03-12-2009
#!/bin/sh
set -x

for file in $(ls `date +%y%m%d0010202.TLG`)
echo "FILE: $file"
grep ^203 $file | cut -d, -f3 | sort | uniq -c | while read line; do
cnt=$(echo $line | cut -d" " -f1)
acct=$(echo $line | cut -d" " -f2)
echo "Account $acct had $cnt 203's"
done
done

when i run this script it gives
ins@ARTMGA01> ./arc.sh
./arc.sh: syntax error at line 4: `$' unexpected
# 16  
Old 03-12-2009
nawk -F, 'NR==FNR{_[$0]=0;next}$1==203{a[$3]++}END{for(i in _){a[i]==""&&a[i]=0;print i" 203s = "a[i]}}' subs.list 0812*.TLG

This way we can only get the stats for combinely for whole month.

I think i am unable to make you understand what i need.i am sorry about that.

This is what i need
uary
i need the count of 203's for each day for each subcriberid for the whole month of feb

then i need to paste it in an excel file which i will do like these
subid 200 302 144 .....
date:
03-02-2009
04-02-2009
...........
.........2009
.........2009

thanks again for all the help

Last edited by archana234; 03-12-2009 at 10:00 PM..
# 17  
Old 03-13-2009
sorry on the first line add "; do"
for file in $(ls `date +%y%m%d0010202.TLG`); do

Based on your last email you will want to redirect the output into a text file and add the date to the output.
You can then import the text file into Excel as a {space} delimited file.
Code:
for file in $(ls 0902*0010202.TLG); do
  day=$(echo $file | cut -c 1-6)
  grep ^203 $file | cut -d, -f3 | sort | uniq -c | while read line; do
    cnt=$(echo $line | cut -d" " -f1)
    acct=$(echo $line | cut -d" " -f2)
    echo "Date 20${day} Account ${acct} had ${cnt} 203's" >> Feb_report.txt
  done
done


Last edited by ldapswandog; 03-17-2009 at 08:49 AM..
# 18  
Old 03-16-2009
ins@ARTMGA01> ./arc.sh
./arc.sh: syntax error at line 4: `$' unexpected

its still giving me a syntax error
# 19  
Old 03-17-2009
your error reports line 4 has a syntax error you need to provide more information. Paste your version of the script. Also some versions of shell do not like the use of "$()" so replace them with back ticks "`" usually found on the tilde "~" key.
# 20  
Old 03-18-2009
ins@ARTMGA01> more arc.sh

#!/bin/sh

set -x



for file in $(ls 0902*0010202.TLG); do

day=$(echo $file | cut -c 1-6)

grep ^203 $file | cut -d, -f3 | sort | uniq -c | while read line; do

cnt=$(echo $line | cut -d" " -f1)

acct=$(echo $line | cut -d" " -f2)

echo "Date 20${day} Account ${acct} had ${cnt} 203's" >> Feb_report.txt

done

done
# 21  
Old 03-18-2009
Try this version with the backticks
Code:
#!/bin/sh
set -x

for file in `ls 0902*0010202.TLG`; do
    day=`echo $file | cut -c 1-6`
    grep ^203 $file | cut -d, -f3 | sort | uniq -c | while read line; do
        cnt=`echo $line | cut -d" " -f1`
        acct=`echo $line | cut -d" " -f2`
        echo "Date 20${day} Account ${acct} had ${cnt} 203's" >> Feb_report.txt
    done
done

Reply With Quote
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