I have the string as follows:
$ echo "$val1"
"$29.95 Carryover Plan 1GB"
Now I can use this method to replace the spaces with underscores
$ echo "NAME_"${val1// /_}"_NAME"
NAME_"$29.95_Carryover_Plan_1GB"_NAME
And can do the same for replacing "
double quotes with nothing
$ echo "NAME_"${val1//'"'/}"_NAME"
NAME_$29.95 Carryover Plan 1GB_NAME
Now I can use sed to do the same - to replace the spaces with underscores
$ echo "$val1" | sed s/" "/_/g
"$29.95_Carryover_Plan_1GB"
And I can then remove the double quotes by adding this sed s/'"'/''/g
$ echo "$val1" | sed s/" "/_/g | sed s/'"'/''/g
$29.95_Carryover_Plan_1GB
So this is what I want (spaces repalaced with underscore and double quotes removed) but can i achieve it using my first approach above e.g.
$ echo "NAME_"${val1// /_}"_NAME"
NAME_"$29.95_Carryover_Plan_1GB"_NAME
This is my attempt
$ echo "NAME_"${${val1// /_//'"'/}}"_NAME"
-sh: "NAME_"${${val1// /_//'"'/}}"_NAME": bad substitution
edit1 this is the sed I can achieve but I want to be able to achieve this by my first approach
$ echo "NAME_"$val1"_NAME" | sed s/" "/_/g | sed s/'"'/''/g
NAME_$29.95_Carryover_Plan_1GB_NAME