0

How do you replace a bash variable right next to a string so the variable you are replacing is not misinterpreted?

For Instance::

NUMBER=33
echo "$NUMBERs"

In my case I want this to echo out "33s" but bash is interpereting this variable as "$NUMBERs" when I want it to be "$NUMBER"

user1601716
  • 1,893
  • 4
  • 24
  • 53
  • 4
    `echo "${NUMBER}s"` – anubhava Sep 13 '18 at 17:35
  • That was it, thanks! – user1601716 Sep 13 '18 at 17:36
  • @anubhava Why answer in a comment? Post in a proper answer so you can get credit and more importantly future searchers will know that the question has an answer that worked. – Gary_W Sep 13 '18 at 17:40
  • 1
    @Gary_W: I was under impression that it must be a duplicate but so far I haven't found exact dup – anubhava Sep 13 '18 at 17:41
  • 1
    More dupes: https://stackoverflow.com/questions/26559617/bash-variable-interpolation-separate-variables-by-a-hyphen-or-underscore, https://stackoverflow.com/questions/46305806/bash-while-read-loop-does-not-properly-recognize-variables, https://stackoverflow.com/questions/43416413/inserting-variable-into-sh-script-command, https://stackoverflow.com/questions/42196891/bash-variable-not-getting-expanded-properly – melpomene Sep 13 '18 at 17:52
  • 1
    @anubhava Fair enough then :-) – Gary_W Sep 13 '18 at 18:30

0 Answers0