'Google Cloud Shell - Echo two Variables does not work as expected [duplicate]

Hi I wanted to write a simple bash script to execute some google cloud commands using the google cloud shell Terminal. Doing this I got always some kind of variable error, so I wrote a simple script to understand what's going on. This is the script:

#! /bin/bash
STR1=string1
STR2=string2
echo $STR1$STR2
echo "My String1= ${STR1} My String2= ${STR2}"

My expected output which I got on my ubuntu terminal was this:

string1string2
My String1= string1 My String2= string2

However when I execute it on cloud shell it looks like this: Cloud Shell Output

For some reason Cloud Shell ignores my first variable. What could be the reason?



Solution 1:[1]

Thanks to Gordon Davisson. My mistake was that I wrote the script on Windows Notepad. Afterwards I had just uploaded the file into my cloud shell. Looks like the Windows line endings created then an error. I tested it by creating the script right in cloud shell via nano and the error disappeared.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kleinfossil