Skip to content

Instantly share code, notes, and snippets.

Created May 11, 2021
What would you like to do?
Linux bash shell addition, subtraction, multiplication and division
# 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