zero length check while
[ -z "$input" ] - returns true if the string has zero length
[ -n "$input" ] -returns true if the string has nonzero length
[ -z $input ] is not syntatically valid, only [ -z "$input" ]
cat while1
input=""
while [ -z "$input" ]; do
read -p "Please give your input" input
done
echo "Thank you for saying $input"
$ bash while1
Please give your input
Please give your input
Please give your inputsome text
Thank you for saying some text
----------------
[ -n "$input" ] -returns true if the string has nonzero length
cat while1
input=""
while [ -z "$input" ]; do
read -p "Please give your input" input
done
echo "Thank you for saying $input"
$ bash while1
Please give your input
Please give your input
Please give your inputsome text
Thank you for saying some text
----------------
Comments
Post a Comment