what is the difference between "0" and "5 - 5" in bash scripts
by skyworld_chen from LinuxQuestions.org on (#4ZP21)
Hi,
I'm learning bash and checked these code:
Code:if [ 0 ]
then
echo "0 is true"
else
echo "0 is false"
fi
if [ expr 5 - 5 ]
then
echo "5 - 5 is true"
else
echo "5 - 5 is false"
fiI got this from CentOS 7 output:
Quote:
I'm confused here: Why the first result is true while the second result is false? Thanks.


I'm learning bash and checked these code:
Code:if [ 0 ]
then
echo "0 is true"
else
echo "0 is false"
fi
if [ expr 5 - 5 ]
then
echo "5 - 5 is true"
else
echo "5 - 5 is false"
fiI got this from CentOS 7 output:
Quote:
./test1.sh 0 is true ./test1.sh: line 19: [: too many arguments 5 - 5 is false |