PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Linux Calculate A Percentage Of A Number

Go down

Linux Calculate A Percentage Of A Number Empty Linux Calculate A Percentage Of A Number

Post by jamied_uk 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
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Linux Calculate A Percentage Of A Number Empty Re: Linux Calculate A Percentage Of A Number

Post by jamied_uk 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
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

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