issue in calculation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting issue in calculation
# 1  
Old 11-06-2008
Bug issue in calculation

Hi all

Already posted this question,i belive i didn't exactly said my question.

I have data files it stored in the different path like
/st/vr/sum.dat
/st/vr/pass.dat
/st/vr/fail.dat

we are not suppoe to mention the hardcode value of the path.

I need to calculate the percentage of pass and fail.

so in my shell script i wrote like

total=$datafile/sum.dat
pass=$datafile/pass.dat
fail=$datafile/fail.dat


i tried in this way:
exp1=$SCR_DIR/$equal_count.dat/$EQUAL_COUNT*100
echo $exp1 | bc

and created an awk script : percentage.awk
{
printf ("%3.2f%%\n", $2/$1 * 100)
exit
}

like this and called through the shell script like

awk -f percentage.awk -v $total -v $pass > pass_percentage.dat

this is also not worked.

if the echo stament is fail to fetch the address of the exp1 and it's not calculating the percentage.

please advice me on this.
# 2  
Old 11-06-2008
Data

Can anybody advice me where am doing mistake?
# 3  
Old 11-06-2008
Please post a samples of input files and required output.
# 4  
Old 11-06-2008
Bug

Hi

This is my script am getting the data from the one CSV file and am taking the count of pass and fail records
and i need to find the percentage of the pass and fail respectively.







#!/bin/ksh
file1=/st/vr/count.csv
pass=/st/vr/pass.dat
fail=/st/vr/fail.dat
total=/st/vr/total_count.dat
equal_percentage=/st/vr/equal_percentage.dat
not_equal_percentage=/st/vr/not_equal_percentage.dat


#ToTAL record count
wc $file1 | awk '{print $1}' >> $total

#chking the count of pass records

grep -cw "pass" $file1 >> $pass

#chking the count of fail records

grep -cw "fail" $file1 >> $fail

#Chk the Eqaul percentage.
equal_percentage=`echo |awk '{print $a / 100 * $b}' a=/st/vr/pass.dat b=/st/vr/total_count.dat`
# 5  
Old 11-06-2008
Hammer & Screwdriver Perhaps this will help

Code:
> pass=25
> fail=19
> total=44
> echo `echo $pass*100/$total | bc`% passed
56% passed
> echo `echo $fail*100/$total | bc`% failed
43% failed

# 6  
Old 11-06-2008
Hi

I already tried in this way it's not working ,

echo `echo $pass*100/$total | bc`% passed

am getting error like Syntax at line 1

b'ze if my pass parameter hold the direct hot code values this statmt will work.

Am holding the pass value ,it again holds the /st/vr/pass.dat.

in this point only it's failing.that's the issue.
hope you understand my problem.
please let me know,if u need more information to help me out.

provide me some other solution to over some this issue.
# 7  
Old 11-06-2008
Question

So your $pass holds the filename location for a file.
That file contains one piece of information: the number of pass'es.

Why not redirect your pass calculation to a variable?
num_pass=$(grep -cw "pass" $file1)
and so on... then what I proposed earlier would work.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calculation

Hi, i have a large file like this: Contig1 1 5 Contig1 2 4 Contig1 3 3 Contig1 4 5 Contig1 5 3 Contig1 6 4 Contig2 1 3 Contig2 2 7 Contig2 3 2 Contig2 4 9 Contig2 5 10 Contig2 6 3 Contig2 7 7 Contig2 8 2 Contig2 9 7 Contig2 10 5 contig1 2 4 contig1 3 3 contig1 4 5 (3 Replies)
Discussion started by: the_simpsons
3 Replies

2. Shell Programming and Scripting

VG calculation in GB

for i in `lsvg` do echo "VG Name:" $i echo "Total VG Size:" lsvg $i |grep "TOTAL PPs:" |awk '{print $7}' | cut -c2- echo "Free VG Size:" lsvg $i |grep "FREE PPs:" | awk '{print $7}' | cut -c2- done The PP Sizes are in MB. I like to have the sizes in GB. Also, I like to have the... (14 Replies)
Discussion started by: Daniel Gate
14 Replies

3. Shell Programming and Scripting

Date calculation, a little different...

Hello eveyone, I am tasked to write an (n)awk script to calculate the days between dates. Now before anyone chastizes me on how many forums there are on date calculation, I have no seen one that takes into account the Julian calender as well. As most know, September of 1752 is when we (the US)... (2 Replies)
Discussion started by: csharp100
2 Replies

4. Shell Programming and Scripting

calculation

Could someone till me what this calculation really means let foo=`date "+(1%H-106)*60+1%M-100"` bar=foo+1440 (4 Replies)
Discussion started by: freddie999
4 Replies

5. Shell Programming and Scripting

summery calculation

Hi All I want to make summery for Date=245Duration=545 Date=245Duration=10 Date=245Duration=278 Date=246Duration=30 Date=246Duration=178 Date=246Duration=414 Date=247Duration=17 Date=247Duration=281 Date=247Duration=9 Date=248Duration=968 Date=248Duration=550 Date=248Duration=1011... (1 Reply)
Discussion started by: nalakaatslt
1 Replies

6. Shell Programming and Scripting

summery calculation

Hi All I want to make summery for Date=245Duration=545 ... (1 Reply)
Discussion started by: nalakaatslt
1 Replies

7. Shell Programming and Scripting

decimal calculation

Hi am calculating the percentage of the pass and fail. Pass: echo `echo 1498*100/1667| bc`% fail: echo `echo 169*100/1667 | bc`% for this am getting PASS= 89% fail =10 % I need to fetch the exact decimal percentage like PASS = 89.8 % FAIL= 10.2 % Please advice me (3 Replies)
Discussion started by: bobprabhu
3 Replies

8. Shell Programming and Scripting

Dynamic calculation

Hi Experts, please see below are the dynamic text files. abc,445,hhh,data,10,country,data,88,city abc,445,hhh,data,10,country,data,88,city abc,445,hhh,data,10,country,data,88,city abc,445,hhh,data,10,country,data,200,city abc,445,hhh,data,10,country,data,88,city,games,100,data,20,basket... (10 Replies)
Discussion started by: shary
10 Replies

9. Shell Programming and Scripting

need help in decimel calculation

hi $lp_count = 25265531 $num_reads = 25280826 result=`echo "scale=2; $lp_count/$num_reads * 100" | bc` echo $result ------------------------------------------------------ o/p: 99.00 ------------------------------------------------------ desired: 99.93 (2 Replies)
Discussion started by: ali560045
2 Replies

10. Shell Programming and Scripting

calculation

Hi, I am in ksh88 I am trying to get the result of the calculation using 3 variables: TOTAL CAPACITY and get the following error: $DB_CAPACITY=(( $DB_SIZE * 100 / $TOTAL )) ksh: syntax error: `((' unexpected I cannot figure out what am I doing wrong... Thanks for any help -A (2 Replies)
Discussion started by: aoussenko
2 Replies
Login or Register to Ask a Question