Echo text immediately after the variable
3 answers
You can use curly braces for this, as you do for many shells:
$min = 7;
$sec = 2;
echo "${min}m ${sec}s";
Result:
7m 2s
The parentheses are used to denote the variable name from the following text in situations where the greedy nature of the variables can cause problems.
So while $minm
trying to provide you with the contents of a variable minm
, ${min}m
will provide you with the contents of a variable min
followed by a letter m
.
+13
source to share