I'm assigning a string (my name is xxxxxx ssddd
) a shell variable(str
)
when echo the variable.
echo $str
my name is xxxxxx ssddd
Why white spaces are not taken in to account?
I'm assigning a string (my name is xxxxxx ssddd
) a shell variable(str
)
when echo the variable.
echo $str
my name is xxxxxx ssddd
Why white spaces are not taken in to account?
Quote your strings in order to preserve white space:
a="four spaces"
echo $a
four spaces
echo "$a"
four spaces
However, when assigning one variable to another, whitespace also is preserved:
a=$b
echo "$b"
four spaces