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
----------------

Comments

Popular posts from this blog

HAproxy logging

tomcat catalina coyote jasper cluster

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all