Concatenate two variables with underscore - question
Hi,
I have question regarding concatenation of two variables with underscore. i.e. (bourne shell) Code:
# var1=123 Thanks! |
Quote:
eg. think about Code:
var=10 You can however use braces to clarify variable names: Code:
var=10 |
But why will this work then:
Code:
# echo $var1-$var2 |
In the bash man page is a section on definitions.
Quote:
By the way, here's a small trick you can use so that the underscore is only inserted if the second variable exists. Of course, it can only be used on shells that support this parameter substitution. Code:
echo "${var1}${var2:+_}${var2}" |
All times are GMT -5. The time now is 12:19 AM. |