Today I spent several hours figuring out how to do string concatenation in a bash script.
I was thinking that it should be quite easy just do
STRING_1=Hello
STRING_2= World
echo $STRING_1$STRING_2
And of course it turns out that it is just that easy. However my problem was that I was using Notepad++ to edit the files (I know, bash on windows?). Without going into the discussion, let's just say it makes sense for my setup :)
But of course I got strange results, it seemed that the second string would be written "on top" of the first string. I finally figured out what the problem was and of course it was because the files was formatted with Windows line breaks and not Unix line breaks. I'm writing this because I need to remember to check these things every time I see strange behavior.
Now I just have to figure out how to force Notepad++ to default to using Unix line breaks.
I was thinking that it should be quite easy just do
STRING_1=Hello
STRING_2= World
echo $STRING_1$STRING_2
And of course it turns out that it is just that easy. However my problem was that I was using Notepad++ to edit the files (I know, bash on windows?). Without going into the discussion, let's just say it makes sense for my setup :)
But of course I got strange results, it seemed that the second string would be written "on top" of the first string. I finally figured out what the problem was and of course it was because the files was formatted with Windows line breaks and not Unix line breaks. I'm writing this because I need to remember to check these things every time I see strange behavior.
Now I just have to figure out how to force Notepad++ to default to using Unix line breaks.