I am trying to pass a multiword argument in a function an echo the result in a simple fashion.
Currently I am doing this:
function myFunction {
multiWordString=""
for ((i=3; i<=$#; i++)); do
multiwordVariable+=" "${!i}
done
echo "multiwordVariable here => $multiwordSTRING"
}
myFunction "$@" otherArgument1 otherArgument2 I am a multivariable element and yeah is rock
You can see there is several drawback in this approach, the insertion of multiple argument, the usage of a loop, the management of my argument positioning to retrieve my string of characters... that makes it a very approximating solution.
I would do something more simple, like just read my variable's string:
multiWordArgument="here an awesome multiword string"
function file_function {
echo $1
}
myFunction $multiWordArgument
maybe someone know a way that is nearer to this process?
thanks
myFunction "$multiWordArgument"
– steve Jan 04 '20 at 20:08