How to concatenate two strings in a bash script?
Example: I would like to concate "foo" and "bar", but WITHOUT creating a new variable for "bar".
VAR="foo"
echo "$VARbar"
This does not work, because it is considered as variable name VARbar.
bash_prompt$ l="aaa"
bash_prompt$ m="bbb"
bash_prompt$ n=$l$m
bash_prompt$ echo $n
bash_prompt$ aaabbb
bash_prompt$ n=$l"bbb"
bash_prompt$ echo $n
bash_prompt$ aaabbb
Bash does string concatenation by default
$ that confuse the answer. Also, make sure you are answering the question. The OP wants to echo $VARbar and to output foobar. Your examples are correct but do not answer it.WITHOUT creating a new variable for "bar". echo $VARbar is what he thought can be an approach, but not necessarily must be . Sorry for the leading $, i copy pested them (my PS1 is just odd, i agree :P) I'll make the change