Created
May 11, 2021 05:05
-
-
Save soiqualang/ad2653abc30a19269012d53af9067d9c to your computer and use it in GitHub Desktop.
Linux bash shell addition, subtraction, multiplication and division
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# read -s -p "Enter Password: " pswd | |
read -p "Enter Num 1: " num1 | |
read -p "Enter Num 2: " num2 | |
# Phép cộng | |
kq=$(($num1 + $num2)) | |
echo "Kết quả phép cộng:" $kq | |
# Phép trừ | |
kq=$(($num1 - $num2)) | |
echo "Kết quả phép trừ:" $kq | |
# Phép nhân | |
kq=$(($num1 * $num2)) | |
echo "Kết quả phép nhân:" $kq | |
# Phép chia | |
kq=$(echo "scale=3; $num1/$num2" | bc -l ) | |
echo "Kết quả phép chia:" $kq | |
# echo $(echo "2/3" | bc -l ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment