Hi Guys,
IF i have to append data to a variable, i simply use the following. What can i do to append data to the beginning?
VAR+="data"
Hi Guys,
IF i have to append data to a variable, i simply use the following. What can i do to append data to the beginning?
VAR+="data"
try
var="Makarand"
var=$var"Dodmise"
$ echo $var
MakarandDodmise
Hello,
This should add text to beginning of the variable.
VAR="data" $VAR
Cheers!
Ranga
That will not work. Remove the space, and, to be sure, double-quote $VAR:
VAR="data""$VAR"
Just to add a comment to these solutions, as variables get expanded inside double quotes, I would have thought only one pair of double quotes is required to enclose both the variable itself as well as the additional data:
VAR="data${VAR}"
My Bad, Typo..
try
akshay@nio:~/tmp$ variable="abc"
akshay@nio:~/tmp$ printf -v variable "%s%s" def $variable
akshay@nio:~/tmp$ echo $variable
defabc