How to concat variable and string in bash script ?
val1 = Variable1 + "any string "
eg :
val1 = $i + "-i-*"
where i = 24thMarch
I want echo val1 :
24thMarch-i-*
What is proper proper to get the solution ?
How to concat variable and string in bash script ?
val1 = Variable1 + "any string "
eg :
val1 = $i + "-i-*"
where i = 24thMarch
I want echo val1 :
24thMarch-i-*
What is proper proper to get the solution ?
Nice.
Mac OS X 10.12 works with following ...
Result
= barfoosometext
Late for the party, my 2 cents for another solu., also works in
zsh
:val1="$i-i-*"
Strings are concatenated by default in the shell.
It's generally considered good practice to wrap variable expansions in double quotes.
You can also do this:
The curly braces are useful when dealing with a mixture of variable names and strings.
Note that there should be no spaces around the
=
in an assignment.