I would like to generate some commands accoring to data stored in a field of mysql table.
To get the data and store them in a variable i do the following
modules=$(/usr/bin/mysql -u $MyUSER -p$MyPASS $DB_NAME -e "SELECT modules FROM myapp WHERE ID=31 " -B -N)
In the database the data is stored like in json format :
["module-name-1","module-2","https:\/\/domain.com\/module\/packages\/mailmdule.zip"]
I want to iterate each element of this list and produce a line with a command that would look like
install module-name-1 -yes --no-prompt install module-2 -yes --no-prompt install https://domain.com/module/packages/mailmdule.zip -yes --no-prompt
Please note that the URL in the last command is formatted differently than it in the json
I was looking for a solution through jq but did not succeed, I have tried to get a clean output :
$((/usr/bin/mysql -u $MyUSER -p$MyPASS $DB_NAME -e "SELECT modules FROM myapp WHERE ID=31 " -B -N)| jq '.[]'))
But i only get
"module-name-1" "module-2" "https:\/\/domain.com\/module\/packages\/mailmdule.zip"
Would appreciate any suggestion