How to concatenate string variables in Bash
Here are few preferred ways to concatenate string variables in bash script
Concatenate string variables in Bash
1.Write the variable one after another in echo
#!/bin/bash
var1="Techieroop"
var2="${var1} Tutorial"
echo "${var2}"
##output
Techieroop Tutorial
2. Use +=
assignment operator:
#!/bin/bash
var="Techieroop"
var+=" Tutorial"
echo "$var"
##output
Techieroop Tutorial
Second method can be used to append to an integer as well
test.sh
#!/bin/bash
int1=18
((int1+=86))
echo "Sum is $int1"
#$ sh test.sh
#Sum is 104
(Visited 307 times, 35 visits today)