====== BASH - Strings - Concatenating Strings ====== To concatenate two variables you can just write them one after another: #!/bin/bash string1="Hello" string2="World" string=$string1$string2 echo "$string is the concatenation of $string1 and $string2." **NOTE:** The following program outputs the string “HelloWorld is the concatenation of Hello and World.”. ---- a='Hello' b='World' c="${a} ${b}" echo "${c}" > Hello World or foo="Hello" foo="${foo} World" echo "${foo}" > Hello World ---- var="abcdefgh" echo ${var:0:(-1 -4)}XYZ returns: abcXYZ