Bash: if statement syntax
A simple test which doesn't work.
Code:
x=10 Code:
bash: [10==10]: command not found Code:
bash-4.1$ bash --version Nevermind found the solution myself. if [$x==10] should be rewritten as if [ $x -eq 10 ] |
Those spaces are important
|
Or when comparing numbers, use the construct designed to do so:
Code:
if (( x == 10 )) |
Code:
x=10 and run the script using bash "scriptname" |
All times are GMT -5. The time now is 09:23 PM. |