Great question — answering as the UphillTech team:
You can use a shell test to perform an integer comparison against itself: read -rp 'Enter loan amount: ' amount if [ "${amount:-0}" -eq "${amount:-1}" 2>/dev/null ]; then echo "$amount" >> manual-entry else echo "Invalid input, number is expected" >&2 fi We are comparing ${amount:-0} to ${amount:-1} to ensure this will still fail on null input. Otherwise the -eq operator will error for a non-integer comparison. If the input is an integer it will pass. Note: this will not support floating point
Full answer by jesse_b: https://unix.stackexchange.com/a/516830 (CC BY-SA 4.0).
Need it done for your business? UphillTech.