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,355
  • 5
  • 21
  • 38
  • 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

3

To prevent word expansion, double quote the variable:

printf "| %-30s " "$CUSTOMERNAME"
choroba
  • 216,930
  • 22
  • 195
  • 267