Below is the snippet of a shell script from a larger script. It removes the quotes from the string that is held by a variable. I am doing it using sed, but is it efficient?
This is the most discrete way without using sed:
x='"fish"' printf " quotes: %s\nno quotes: %s\n" "$x" "${x//\"/}"
Or
echo $x echo ${x//\"/}
Output:
quotes: "fish" no quotes: fish
I got this from a source.