0

I wanted something like this:

  CUSTOMERNAME="THIS IS A TEST"
  printf "| %-30s " $CUSTOMERNAME

But the problem is, that the value CUSTOMERNAME has some space. The output looks likes this:

 | THIS                           | IS                             | A                              | TEST

But I wanted something like this

 | THIS IS A TEST                |

What can I do? Any ideas?

Thanks, Hauke

Hauke
  • 1,405
  • 5
  • 23
  • 44
  • possible duplicate of [I just assigned a variable, but echo $variable shows something else](http://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else) – Etan Reisner May 07 '15 at 21:24

1 Answers1

4

To prevent word expansion, double quote the variable:

printf "| %-30s " "$CUSTOMERNAME"
choroba
  • 231,213
  • 25
  • 204
  • 289