Languages
[Edit]
EN

Bash - concatenate two string variables

0 points
Created by:
Mark-Rotteveel
537

In this article, we would like to show you how to concatenate string variables in Bash.

Quick solution:

 

Practical example

Edit

In this example, we create a and b variables inside a script.sh file and concatenate them into one - result with space between them. At the end we display the result using echo command.

script.sh file:

Run in command line:

Output:

Note:

In this case, we don't need curly braces ({}). They are needed only when we want to limit variable name (explicitly indicate variable name).

 

Alternative titles

  1. Bash - concatenate two strings
  2. Bash - concat two strings
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join