Bash Append Text To a Variable

How do I append additional text a variable? For e.g., I’ve a vech set as follows:
vech=”London”
I’d like to add (append) “Bus” word to $vevh under UNIX scripting using bash?

You can simply use the following syntax:

vech="London"
vech="$vech Bus"
echo $vech

If you don’t want to update $vech, but just want to print it on screen, enter:

echo "$vech Bus"

You can also append another variable:

x="Mango"
y="Pickle"
x="$x $y"
echo "$x"

Finally:

x="Master"
# print 'Master' without a whitespace i.e. print Mastercard as a one word #
echo "${x}card"

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.