Xedrox
October 4, 2012, 11:44am
1
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.
rdrtx1
October 4, 2012, 11:46am
2
A="Hello "
B="Hello"
echo "${A}${B}"
Hello Hello
1 Like
Xedrox
October 4, 2012, 11:46am
3
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
Xedrox
October 4, 2012, 12:04pm
6
The problem is solved. Thank's everyone.