Home > Mobile >  Bash Shell no printed output after checking a -lt condition
Bash Shell no printed output after checking a -lt condition

Time:07-28

I am trying to test if Variable X is less than 50, if yes then print it (echo it), but I am getting no output!

X=1
if [$X -lt 50]
then 
    echo $X
fi

CodePudding user response:

Try with the following :

X=1
if [ "$X" -lt 50 ]
then 
    echo $X
fi

Whitespace matters in bash.

  • Related