01-29-2017
Working out percentage in shell script
Hi All,
I currently have a shell script which is pulling multiple counters from various sources. Due to the counters being cumulative counters I've got some code to work out the delta from the last reading and current which is working fine.
The problem i have now is being able to work out the success rate as a percentage.
Normally I would just take success and divide by attempts then multiply this by 100 which would give my success rate at a percentage (i'd like it to 2 decimal places).
How can this be done in a shell script ?
Any help is apprecaited as always.
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Trying to figure out why this works:
printpwd.pl
#!/usr/bin/perl
use CGI::Carp qw( fatalsToBrowser );
print "Content-type: text/html\n\n";
$A = system("pwd");
$A = `pwd`;
print "$A\n";
^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Discussion started by: phpfreak
5 Replies
2. UNIX for Dummies Questions & Answers
Hi there,
I am totally new to Unix, I am trying to work out the percentage between two values in a ksh shell script and assign the result to a variable.
Value1=577
Values2=244
So the calculation would be as follows:
((Value1 - Value2) / Value1) * 100
How would I be able to achieve... (2 Replies)
Discussion started by: NextLevelAndi
2 Replies
3. Shell Programming and Scripting
hello,
please can you help me.
jj and kk are two numbers which are the result of an sql program.
I would like to calculate the ratio jj/kk*100.
I have done this:
ratio=$((jj/kk * 100)) or ratio=`expr $jj \/ expr $kk) but the result is 0
What can i do?
Thanks for help. (3 Replies)
Discussion started by: likeaix
3 Replies
4. Programming
Hi all,
I havea log of data.log
bear,10000,white
bear,5000,black
chicken,2000,white
chicken,4000,yellow
chicken,3000,black
lion,6000,yellow
lion,1000,white
How can we have shell script to get the percentage of each animals?
Thanks. (8 Replies)
Discussion started by: sabercats
8 Replies
5. Shell Programming and Scripting
Shell Scipt: temp.sh
su - <$username>
expect pass.exp
Expect script: pass.exp
#!/usr/bin/expect -f
# Login
#######################
expect "Password: " send "<$password>\r"
it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Discussion started by: bhavesh.sapra
2 Replies
6. UNIX for Dummies Questions & Answers
Hello,
I am trying to compute the percentage in a script as shown below:
PerCover=`echo "scale=2 ; 100 \* ($InputCover/$Total)" | bc`
However the PerCover value is blank/null. What do I need to do differently?
Thanks for your input!
~Guss (1 Reply)
Discussion started by: Gussifinknottle
1 Replies
7. Shell Programming and Scripting
. /home/bscs6/.kshrc
set -x
monthy=`date +%m`
daty=`date +%d`
yeary=`date +%Y`
cd /home/bscs6/scripts
sqlplus sysadm/sysadm@SEGODI @lms_profile.sql
mv /home/bscs6/scripts/lmsprofile.log /home/bscs6/scripts/LMS_PROFILE_DUMP_$daty$monthy$yeary.txt
gives me the error below:
LMS_PROFILE.sh:... (3 Replies)
Discussion started by: malefho
3 Replies
8. Shell Programming and Scripting
Dear All,
I have script.
Dest=""
IFS='
'
for translation in $(echo $MY_MAP)
do
t1=$(echo $translation | cut -d"=" -f1)
t2=$(echo $translation | cut -d"=" -f2| cut -d"," -f1)
if
then
Dest=$UNX/$u_product_path/$u_study_path/$UNXTR/$t2
break;
... (4 Replies)
Discussion started by: yadavricky
4 Replies
9. Shell Programming and Scripting
Hi there
I am middle of writing a script to allow me to see the % of the memory which is being used.
When I submit my script I don't get any errors but I just get a blank output.
Any pointers?
available=`free -m | grep available`
if
then
... (7 Replies)
Discussion started by: simpsa27
7 Replies
10. HP-UX
having two columns, A and B.. i need to add another column C in a file and calculate the percentage based on the column A and B. (COLUMN B/ COLUMN A *100) . "|" is delimiter separating the A and B.. need C column with the percentage value. Thanks for your help
100|50 |50% ... (6 Replies)
Discussion started by: kartikirans
6 Replies
LEARN ABOUT DEBIAN
ibqueryerrors
IBQUERYERRORS(8) OpenIB Diagnostics IBQUERYERRORS(8)
NAME
ibqueryerrors.pl - query and report non-zero IB port counters
SYNOPSIS
ibqueryerrors.pl [-a -c -r -R -C <ca_name> -P <ca_port> -s <err1,err2,...> -S <switch_guid> -D <direct_route> -d]
DESCRIPTION
ibqueryerrors.pl reports the port counters of switches. This is similar to ibcheckerrors with the additional ability to filter out
selected errors, include the optional transmit and receive data counters, report actions to remedy a non-zero count, and report full link
information for the link reported.
OPTIONS
-a Report an action to take. Some of the counters are not errors in and of themselves. This reports some more information on what the
counters mean and what actions can/should be taken if they are non-zero.
-c Suppress some of the common "side effect" counters. These counters usually do not indicate an error condition and can be usually be
safely ignored.
-r Report the port information. This includes LID, port, external port (if applicable), link speed setting, remote GUID, remote port,
remote external port (if applicable), and remote node description information.
-R Recalculate the ibnetdiscover information, ie do not use the cached information. This option is slower but should be used if the
diag tools have not been used for some time or if there are other reasons to believe that the fabric has changed.
-s <err1,err2,...>
Suppress the errors listed in the comma separated list provided.
-S <switch_guid>
Report results only for the switch specified. (hex format)
-D <direct_route>
Report results only for the switch specified by the direct route path.
-d Include the optional transmit and receive data counters.
-C <ca_name> use the specified ca_name for the search.
-P <ca_port> use the specified ca_port for the search.
AUTHOR
Ira Weiny
<weiny2@llnl.gov>
OpenIB Jan 24, 2008 IBQUERYERRORS(8)