How do you append to an already existing string?

Solution 1:

In classic sh, you have to do something like:

s=test1
s="${s}test2"

(there are lots of variations on that theme, like s="$s""test2")

In bash, you can use +=:

s=test1
s+=test2

Solution 2:

$ string="test"
$ string="${string}test2"
$ echo $string
testtest2

Solution 3:

#!/bin/bash
message="some text"
message="$message add some more"

echo $message

some text add some more

Solution 4:

teststr=$'test1\n'
teststr+=$'test2\n'
echo "$teststr"