I'm trying to test a simple if
statement by running it from the command line but bash wont run it.
~$ myVar = 23
run a conditional statement
~$ if [$myVar -eq 23] then echo "myVar is 23" fi
Bash wont run this, what am I missing here?
I'm trying to test a simple
run a conditional statement
Bash wont run this, what am I missing here? |
||||
|
To declare a variable spaces matter:
The following is missing semicolons and the spacing inside the brackets matters:
Should be:
And:
Could also be written without semicolons if written on multiple lines:
And it is usually suggested to use double quotes on variables. Single quotes are used for literal strings. This is also valid syntax with one semicolon:
|
|||||||||||||||||||||
|