0

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?

Henk Langeveld
  • 8,088
  • 1
  • 43
  • 57
Jeevanantham
  • 5
  • 1
  • 6

1 Answers1

1

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
Henk Langeveld
  • 8,088
  • 1
  • 43
  • 57