![]() |
Simple shell script is driving me crazy
Hi,
I am trying to write a shell script using if .. then.. else.. should be fairly easy, but my script always outputs else function. For example the script bellow always outputs "Shame on you!!" even when the ANSWER is yes: #!/bin/bash echo "Are you a good person?" read ANSWER if [$ANSWER="yes"]; then echo "Good for you!!" else echo "Shame on you!" fi And I already tried writing "if" statement different ways, but outcome is always the same... I am obviously missing a point here, and I tried looking up simmilar simple problems on internet, and the ones I found work fine.. Don't see what mine is missing though.. Please help Ner |
right code:
#!/bin/bash echo "Are you a good person?" read ANSWER if [ $ANSWER == "yes" ] ; then echo "Good for you!!" else echo "Shame on you!" fi |
yeah, I tried that too, but it gives me
Line 4: [yes==yes]: command not found Shame on you!! |
the spaces inside the brackets matters
Code:
if [ $ANSWER == "yes" ]Code:
if [$ANSWER=="yes"] |
thank a lot Demonbane! :)
didn't think spaces would matter much.. but now it works!! :) |
| All times are GMT -5. The time now is 11:40 AM. |