by @saigowthamr

How to concatenate variables in Bash

Home » bash » How to concatenate variables in Bash

To concatenate a string to the existing string in the bash we need to use += operator as shown in the 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