Linux Calculate A Percentage Of A Number

Go down

Linux Calculate A Percentage Of A Number

Post by jamied_uk on 26th May 2018, 22:56



Code


Code:
#!/bin/bash
# (c) J~Net 2018
#
#
# Usage:   ./calc.sh 50
#
#
#
# 40% PMPO VAL RMS = WATTS VAL EST.
#
#
#
myvar=$1
#
if [ $# -eq 0 ]
  then
    echo "Enter PMPO Value To Convert To RMS"
    read myvar
fi
#
#
# This returns 40% of given number!
#
calc(){
awk "BEGIN{print $*}";
}
#
#
res=$(calc $myvar/100*40)
#
#
echo "40% Of $myvar Watts PMPO Is $res" Watts RMS
avatar
jamied_uk
Admin

Posts : 2427
Join date : 2010-05-09
Age : 35
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Linux Calculate A Percentage Of A Number

Post by jamied_uk on 28th May 2018, 12:52

Increase number by 40%



Code:
#!/bin/bash
# (c) J~Net 2018
# jnet.forumotion.com/t1626-linux-calculate-a-percentage-of-a-number#2502
#
# Usage:   ./rms_to_pmpo.sh 5
#
# 40% PMPO VAL RMS = WATTS VAL EST.
#
myvar=$1
#
if [ $# -eq 0 ]
  then
    echo "Enter RMS Value To Convert To PMPO"
    read myvar
fi
#
# This returns + increase of 40% of a given number!
#
calc(){
awk "BEGIN{print $*}";
}
#
#
res=$(calc $myvar*100/40)
#
#
echo "$myvar Watts RMS Is $res" Watts PMPO
avatar
jamied_uk
Admin

Posts : 2427
Join date : 2010-05-09
Age : 35
Location : UK

http://address-shortner.co.uk

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum