Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- while true
- do
- first=""
- operator=""
- second=""
- read first operator second
- if [[ $first == "exit" ]]
- then
- echo "bye"
- exit
- fi
- if [[ $first == "" || $second == "" ]]
- then
- echo "error"
- exit
- fi
- if [ "$operator" != "+" ] && [ "$operator" != "-" ] && [ "$operator" != "*" ] && [ "$operator" != "/" ] && [ "$operator" != "%" ] && [ "$operator" != "**" ]
- then
- echo "error"
- exit
- fi
- let "result = $first $operator $second"
- echo $result
- done
Advertisement