#!/bin/bash # Script to display sum of two number and to do calculations such as +, -, / etc # ------------------------------------------------------------------------- # Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ---------------------------------------------------------------------- echo "**** My calculator ****" echo "M A I N - M E N U" echo "1. Multiplication" echo "2. Subtraction" echo "3. Remainder" echo "4. Divide" echo -n "Please select your choice (1-4) : " read choice echo -n "Enter your first number : " read n1 echo -n "Enter your second number : " read n2 if [ $choice -eq 1 ] then answer="$n1 x $n2 = $(( $n1 * $n2 ))" elif [ $choice -eq 2 ] then answer="$n1 - $n2 = $(( $n1 - $n2 ))" elif [ $choice -eq 3 ] then answer="$n1 % $n2 = $(( $n1 % $n2 ))" elif [ $choice -eq 4 ] then answer="$n1 / $n2 = $(( $n1 / $n2 ))" else echo "Sorry please select number between 1-4 only" exit 1 fi echo $answer
Get the latest tutorials on SysAdmin, Linux/Unix, Open Source, and DevOps topics:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 5 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
why ,if I input -1 + 0.009 = -,991 . Where is these zero??
this is modular division not division
hi this is good but i am getting only 0 in division ….
Hi ! everything is working fine. Thanks
but when i try to print * . it prints all the files in the current directory. I am new to Unix so please help me out.
Thanks :)
THIS REALY IS OF HELP TO ME
THANKS GUY