by @codeexamples

How to concatenate variables in Bash

Home » bash » How to concatenate variables in Bash

To concatenate a string to the existing string, we need to use += operator in the bash.

Here is an below example:

name="code"
name+="example"

echo "$name"

Output:

codexample

If you want to concatenate or join two variables in the bash you can do it like this.

first="code"
last="example"
name="$first $last"

echo "$name"

Output:

code example