(I apologize in advance: I don't know whether my problem concerns rather the code syntax or the file system and would - in the latter case -rather fit into a Linux forum)
I'm trying to set up a litte shell script. But as soon as it comes to multiline statements, I came across a strange behaviour.
It took the example blow from a tutorial page:
number=1
if [ $number = "1" ]; then
echo "Number equals 1"
else
echo "Number does not equal 1"
fi
That works fine if I connect via PuTTy to my virtual linux machine (openSUSE 13.1) and copy&paste the code. It does what is expected.
But when I create a file named shell_test.sh (connected via SFTP Net Drive) containing the content below
#!/bin/bash
number=1
if [ $number = "1" ]; then
echo "Number equals 1"
else
echo "Number does not equal 1"
fi
and call it from the command line with bash shell_test.sh
I get an error:
line 7: syntax error near unexpected token `fi'
The same happens with a for loop. The syntax error is then near the token "do".