I think file.sh is with CRLF line terminators.
run
dos2unix file.sh
then the problem will be fixed.
You can install dos2unix in ubuntu with this:
sudo apt-get install dos2unix
More Related Contents:
- How to concatenate string variables in Bash
- How do I iterate over a range of numbers defined by variables in Bash?
- Why should there be spaces around ‘[‘ and ‘]’ in Bash?
- Why does shell ignore quoting characters in arguments passed to it through variables? [duplicate]
- Dynamic variable names in Bash
- How to escape single quotes within single quoted strings
- How to use double or single brackets, parentheses, curly braces
- When do we need curly braces around shell variables?
- Are double square brackets [[ ]] preferable over single square brackets [ ] in Bash?
- Brace expansion with variable? [duplicate]
- What is the benefit of using $() instead of backticks in shell scripts? [duplicate]
- Usage of :- (colon dash) in bash
- Why equal to operator does not work if it is surrounded by space?
- What is the purpose of “&&” in a shell command?
- Tilde in path doesn’t expand to home directory
- Test for non-zero length string in Bash: [ -n “$var” ] or [ “$var” ]
- What is the meaning of the ${0##…} syntax with variable, braces and hash character in bash?
- Ternary operator (?:) in Bash
- Compound ‘if’ statements with multiple expressions in Bash
- What is the difference between ${var}, “$var”, and “${var}” in the Bash shell?
- Why source command doesn’t work with process substitution in bash 3.2?
- Using the && operator in an if statement
- How to escape history expansion exclamation mark ! inside a double quoted string?
- bash: $[] vs. $(())
- What does “plus colon” (“+:”) mean in shell script expressions?
- osascript using bash variable with a space
- How to suppress variable substitution in bash heredocs
- Why equal to operator does not work if it is not surrounded by space?
- Rsync syntax error when run from bash script
- What is the proper way to test a Bash function’s return value?