How do you append to an already existing string? How do you append to an already existing string? bash bash

How do you append to an already existing string?


In classic sh, you have to do something like:

s=test1s="${s}test2"

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

In bash, you can use +=:

s=test1s+=test2


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


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

some text add some more