I am new to shell scripting
I am indenting to convert a string like:
abc def ghi
to
"abc","def","ghi"
This is what I have tried:
testvar= "abc def ghi"
a='"';
res="";
coma=","
for i in $testvar
do
vals=(${i//__/ })
if [ -z "$res" ]; then
$res= $res$a$vals$a
else
$res=$res$coma$a$vals$a
fi
done
echo $res
Its giving this error:
$bash -f main.sh
main.sh: line 4: abc def ghi: command not found
What wrong am I doing? Is there any better way to do this?