I am trying to extract value from a JSON file using jq
on Ubuntu. When I echo
out directly, it works and returns the value to the console. But when I try to assign the extracted value to a variable and echo
out, returns nothing to console.
The following works:
#!/bin/sh
echo '{"USERNAME":"TRX-101","PASSWORD":":g&fg#/H"}' | jq .PASSWORD
The following does NOT work:
#!/bin/sh
VAR = '{"USERNAME":"TRX-101","PASSWORD":":g&fg#/H"}' | jq .PASSWORD
echo $VAR
My ultimate goal is to use the value from $VAR
to do other operations within the shell script (ex: send the value to a XML file etc.)