I have this set of example here to test if the user has keyed in any data after he presses enter.
echo -n "Type a digit or a letter > "
read character
blank=""
if [ "$character" != "$blank"]; then
echo "You typed something"
else
echo "Enter something"
fi
The code above should be testing if the variable contains anything, but I can't seem to get it to work, any help ? Much appreciated.
[ -n STRING ]
test: mywiki.wooledge.org/BashGuide/TestsAndConditionals ...[]
should be separated by spaces from other symbols:[ "$character" != "$blank" ]
But much better use-n
options fortest