Home > computers > linux > bash > bashtestzero | About
Home > Computers > programming > scripting > bash > bashtestzero | About

To test for emptiness, Just use square braquets around the variable like this :

if [ $var ]
then
  echo $var isn't empty
else
  echo $var is empty
fi

To test for zero, use double parens (w/o the dollar) like this :

if (( $var ))
then
  echo $var isn't zero
else
  echo $var is zero
fi

contact : @ychaouche yacinechaouche at yahoocom


QR Code
QR Code bashtestzero (generated for current page)