Concat strings in a shell script [duplicate]

Solution 1:

How about this:

var="${var}string"

Solution 2:

It depends on the shell, but since question was tagged bash:

var='my'
var=$var'string'

Solution 3:

No. For various reasons.

# most sh-compatible shells
var="my"
var="$var string"

# advanced shells
var="my"
var+=" string"