Low Orbit Flux Logo 2 D

Bash Concatenate Strings

Concatenating strings in a BASH is easy. We’re going to show you how to do this. We also have some examples.


Here is an example:

a="Apples and Oranges"     # first string
b=" are good."             # second string
c="$a$b"                   # concatenate

echo $c                    # new string

The output will look like this:

Apples and Oranges are good.

Here is another example:



echo "I like to eat $a and $b but not $c."

The output will look like this:

I like to eat apples and oranges but not rocks.