Quote:
Originally Posted by Garrett85
On the program below the if statement that is within the while block is executing even when that if condition fails. Any ideas?
|
It works for me:
Code:
+ read -p 'Enter a number no higher than the billions range' NUM
Enter a number no higher than the billions range120
+ NUMBEROFDIGITS=3
++ expr 3 / 3
+ NUMBEROFGROUPS=1
+ ISEVEN=true
+ FindNumberOfGroups
++ expr 3 % 3
+ [[ 0 -ne 0 ]]
+ echo 1
1
+ '[' 1 -gt 0 ']'
+ [[ true == false ]]
+ D1=1
+ D2=2
+ D3=0
+ echo '1 2 0'
1 2 0
+ let NUMBEROFGROUPS--
+ '[' 0 -gt 0 ']'
However, the condition is quite confusing because the variable is misnamed: ISEVEN actually means number of digits is a multiple of 3, nothing to do being even at all...
Quote:
Originally Posted by NullTerminator
I tried with [[ ]] or [ ] and is seemed to work either way. I don't know why to use [[ ]]
|
What is the difference between test, [ and [[ ?