I want to assign the string contained in $value
to multiple variables.
Actually the example I gave before (var1=var2=...=$value
) was not reflecting exactly what I wanted.
So far, I found this but it only works if $value
is an integer:
$ let varT=varz=var3=$value
How can I do that?
Best Answer
In my opinion you're better of just doing the more readable:
But if you want a very short way of accomplishing this then try:
Edited: using brace expansions instead of printf and declare instead of eval, which could be dangerous depending on what's in
$value
.Cf. EDIT1: You could still use brace expansions in the new case:
It's safer than the
printf
approach in the comments because it can handle spaces in$value
.