Concatenate strings in Bash
In order to concatenate strings in Bash, we use the assignment operator +=
.
This operator appends the string on the right side of the operator to the string on the left side of the operator.
For example, if we have two strings, str_1
and str_2
, and we want to concatenate them, we would use the following statement:

As you can see from the example above, when we echo str_1
after concatenating it with str_2
, it prints out HelloWorld
without any space between the two strings.
If we wanted to add a space between the two strings during concatenation, we could have done it like this:

Alternate way
If you don't want to use the assignment operator +=
, you can concatenate strings by just writing them one after another.

If you're interested and want to learn more schedule a demo or visit our documentation.