The issue:I need to assign a variable a value that is decently long.All the lines of my script must be under a certain number of columns.So, I am trying to assign it using more than one line.It's simple to do without indents:VAR=This displays without \any issues.echo ${VAR}Result:This displays without any issues.However with indents:    VAR=This displays with \    extra spaces.    echo ${VAR}Result:This displays with      extra spaces.How can I elegantly assign it without these spaces?
How to assign a string value to a variable over multiple lines while indented?
variable
Here the issue is that you are surrounding the variable with double quotes (). Remove it and things will work fine.    VAR=This displays with \    extra spaces.    echo ${VAR}Output This displays with extra spaces.Here the issue is that double quoting a variable preserves all white space characters. This can be used in case if you explicitly need it.For example,$ echo Hello     World    ........ ...            ....will printHello     World    ........ ...            ....And on removing quotes, its different$ echo Hello     World    ........ ...            ....Hello World ........ ... ....Here the Bash removes extra spaces in the text because in the first case the entire text is taken as a single argument and thus preserving extra spaces.But in the second case echo command receives the text as 5 arguments.Quoting a variable will also be helpful while passing arguments to commands.In the below command, echo only gets single argument as Hello World$ variable=Hello World$ echo $variableBut in case of the below scenario echo gets two arguments as Hello and World$ variable=Hello World$ echo $variable