foo="Hello"
foo="${foo} World"
echo "${foo}"
> Hello World
In general to concatenate two variables you can just write them one after another:
a="Hello"
b='World'
c="${a} ${b}"
echo "${c}"
> Hello World
More Related Contents:
- How do I iterate over a range of numbers defined by variables in Bash?
- Difference between single and double quotes in Bash
- Command not found error in Bash variable assignment
- When do we need curly braces around shell variables?
- Why equal to operator does not work if it is surrounded by space?
- What is the purpose of “&&” in a shell command?
- Test for non-zero length string in Bash: [ -n “$var” ] or [ “$var” ]
- What is the difference between ${var}, “$var”, and “${var}” in the Bash shell?
- What does “plus colon” (“+:”) mean in shell script expressions?
- Why equal to operator does not work if it is not surrounded by space?
- What does 2>&1 mean here?
- Input data to a shell script [closed]
- Dynamic variable names in Bash
- Are double square brackets [[ ]] preferable over single square brackets [ ] in Bash?
- What is the purpose of the : (colon) GNU Bash builtin?
- How to store standard error in a variable
- Checking from shell script if a directory contains files
- Trying to split a string into two variables
- Escape dollar sign in string by shell script
- Piping tail output though grep twice
- bash set -e and i=0;let i++ do not agree
- Relative paths based on file location instead of current working directory [duplicate]
- osascript using bash variable with a space
- Counting lines or enumerating line numbers so I can loop over them – why is this an anti-pattern?
- Execute command containing quotes from shell variable [duplicate]
- pipe stdout and stderr to two different processes in shell script?
- In bash, is there an equivalent of die “error msg”
- How do I integrate MSYS2 shell into Visual studio code on Window?
- How to properly nest Bash backticks
- Subtract two variables in Bash