No delete black spaces!

Hi,

I have the next problem, i am triying to concatenate two variables with white spaces at the cornes, but the shell deletes them.

For example i have the next code:

A="Hello "
B="Hello"

echo $A$B

output: Hello Hello

You can see only one space between the words, and i put 5 space after the first "Hello".

How can i keep this spaces for cancatenate two words? :wall::wall:

Thanks!

P.D. Sorry for my english, it is very bad.

 
A="Hello      "
B="Hello"
echo "${A}${B}"
Hello      Hello
1 Like

This page did to me the same problem ahaha white example code. I will put it again. Imagine the "_" is a simple space.

A="Hello     "
B="Hello"

echo $A$B

output:

Hello Hello
A="Hello     "
B="Hello"
echo "$A$B"
1 Like

In echo, to preserve white-space contained in the variable value, you need to enclose the variable evaluation in double quotes. Didn't you read what rdrtx1 suggested?

1 Like

The problem is solved. Thank's everyone.