Issue
I have a string containing quotes and backslahes:
-options \'{"version": "http"}\'
I would like to initialize a variable PARAM
with this string.
How this can be done in bash?
I thought of adding it to an array: PARAMS=(-options \'{"version": "http"}\')
but the output I am getting is: -options '{version: http}'
i.e. without the slashes.
Expected output: -options \'{"version": "http"}\'
Can someone please suggest?
Solution
This looks ok to me.
test="-client-options \\'{\"quic-version\": \"h3\"}\\'"
echo "$test"
t2=("$test" "etc")
echo ${t2[@]}
Escape every inner " and double escape for a persisting escape
Answered By - Zaira Answer Checked By - Terry (WPSolving Volunteer)