You can use variable substitution or string concatenation operator to concatenate two strings in Linux Bash Shell as shown in the below example –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
s1="hello" s2="world" echo "${s1} ${s2}" ## Returns hello world echo "${s1} ${s2}!" ## Returns hello world! echo "${s1} debjeet" ## Returns hello debjeet echo "$s1 world" ## Returns hello world ## Using string append operator s3+=$s1" debjeet" echo $s3 ## Returns hello debjeet ## Another way when using printf s3=$(printf "%s %s" "$s1" "$s2") echo $s3 ## Returns hello world ## Concatinating numbers i1=25 i2=33 echo "${i1}${i2}" ## Returns 2533 |