I need to concatenate 2 strings in bash, so that:
string1=hello
string2=world
mystring=string1+string2
echo mystring
should produce
helloworld
|
In case you need to concatenate variables with literal strings:
|
|||||
|
You don't need to use {} unless you're going to use bash variable parameters or immediate append a character that would be valid as part of the identifier. You also don't need to use double quotes unless you parameters will include special characters.
|
|||
|
If you want to concatenate a lot of variables you can also use
As mentioned by other answers the {} are not needed here but I personally always use them to avoid some syntax errors.
|
|||
|