Concatenate Strings

Option 1

$ VAR1="Hello"
$ VAR2="World"
$ VAR3="${VAR1}, ${VAR2}"
$ echo "${VAR3}"

Option 2

We can also use += operator to concatenate strings

$ VAR1="Hello, "
$ VAR2="World!"
$ VAR1+="${VAR1}"
$ echo "${VAR1}"

Source: Linuxize

Last updated