Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

Calculate float values with menu using bash script

echo
echo '================ Values: ================'
echo
echo -e "Enter first value: c"
read -r a

echo -e "Enter second value: c"
read -r b

echo
echo '================ Menu: ================'
echo
echo "1. Value addidtion"
echo "2. Value multiplition"
echo "3. Value division"
echo "4. Value subtraction"
echo "5. Value modules"
echo
echo -e "Enter your choice: c"
read -r evalres

case $evalres in
1) echo "$a + $b = `bc <<< "scale=1; $a + $b"`";;
2) echo "$a * $b = `bc <<< "scale=2; $a * $b"`";;
3) echo "$a / $b = `bc <<< "scale=2; $a / $b"`";;
4) echo "$a - $b = `bc <<< "scale=1; $a - $b"`";;
5) echo "$a % $b = `bc <<< "scale=2; $a % $b"`";;
*) echo "invalid option selected.";;
esac
Comment

PREVIOUS NEXT
Code Example
Shell :: linux enable numlock on boot up 
Shell :: How do I check my graphics card size in Linux? 
Shell :: linux between subshell variables 
Shell :: Command to create a hardlink 
Shell :: command to ceck number of lines or words in a file 
Shell :: timotei felvinczi githbun 
Shell :: push to an existing branch 
Shell :: Payload create wireless network association (auto connect) pineapple 
Shell :: guardar vi 
Shell :: docker cleanup - Remove Docker Images, Containers, Networks & Volumes 
Shell :: curl output readable json 
Shell :: subtract 
Shell :: npm ldapjs 
Shell :: powershell start exe hidden 
Shell :: show the number of stars in readme github 
Shell :: flask shell context processor 
Shell :: ssh no host key files found 
Shell :: update pulumi 
Shell :: Error getting SSL certificate "default/tls-secret": local SSL certificate default/tls-secret was not found. Using default certificate 
Shell :: git change upstream url 
Shell :: copy one file to several directories 
Shell :: aws cli delete multiple buckets 
Shell :: EFS mounting on EC2 Instances 
Shell :: bash condition structure 
Shell :: bash bracket operators 
Shell :: Install both Heimdall Proxy and Central Console on a single host 
Shell :: svn checkout directories recursively 
Shell :: docker compose share gpu 
Shell :: remove outdated branches git 
Shell :: git push rebase 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =