Printing double quotes in echo command

Please help me to use echo or printf type of command to print some value from variable within double quotes - I want to print the double quote ( " ") also.

I tried

#!/bin/bash
VALUE=some_value
echo '{"value" : "$VALUE"}'

I was expecting the above script would produce ..

{"value" : "some_value"}

But I am not getting the desired result. Rather the above script is producing

{"value" : "$VALUE"}

Thank you very much

The single quotes are preventing variable expansion. Try:

#!/bin/bash
VALUE=some_value
echo "{\"value\" : \"$VALUE\"}"

or

#!/bin/bash
VALUE=some_value
printf '{"value" : "%s"}\n' "$VALUE"

Got the answer from other threads..

echo "{\"javapath\" : \"$JAVAPATH\"}"

:slight_smile:
Thanks

Or

echo '{"value" : "'"$VALUE"'"}'

a concatanation of 'string' "string" 'string'.
$VALUE is evaluated (but not otherwise expanded) because it's inside "string".