This is a sample bash as you see in two ways:
1)First
#!/bin/bash
number=0
echo "Your number is: $number"
IFS=' ' read -t 2 -p "Press space to add one to your number: " input
if [ "$input" -eq $IFS ]; then #OR ==> if [ "$input" -eq ' ' ]; then
let number=number+1
echo $number
else
echo wrong
fi
2)Second:
#!/bin/bash
number=0
echo "Your number is: $number"
read -t 2 -p "Press space to add one to your number: " input
case "$input" in
*\ * )
let number=$((number+1))
echo $number
;;
*)
echo "no match"
;;
esac
Now the question:
With these two ways, how can I check if the input parameter is white space
or null
?
I want to check both white space
or null
in bash.
Thanks