How to concatenate string variables in Bash

Explanation

The string is a collection of objects. Objects can be of the same kind or different. And to concatenate string means we have two different strings and we have to join them. Concatenation means the joining of two strings. And to concatenate string variables in Bash we have to do is :

foo="Hello"
foo="${foo} World"
echo "${foo}"
> Hello World

So in simple terms to concatenate two variables you can write them one after another:

a='Hello'
b='World'
c="${a} ${b}"
echo "${c}"
> Hello World

 

 

Also read, Differences between a HashMap and a Hashtable in Java?

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *