i have a variable $hostgroup that has this type of content in it, that could either be
word1
word1,word2
word1,word2,word3
and so on...
what can i do to make it look like this?
"word1"
"word1","word2"
"word1","word2","word3"
basically if its one word to just add the quotes("") around it, and if there are 2+ words to also seperate them by a comma(,) and to assign the result to a new variable.
i have tried to spearate the words to multiple lines like this
echo "${hostgroup//,/$'\n'}" > hostgrp
and then try to append them to the same line again with the needed alterations
for i in $(cat hostgrp)
do
hgrp=`echo -n "\"$i\","`
done
but it just makes the ouptut look like this
"word1",
"word1 word2",
...
thanks in advance :)