Issue
The bash script sends a curl. The curl response example is following:
{"code":"2aaea70fdccd7ad11e4ee8e82ec26162","nonce":1541355854942}
I need to get the code "2aaea70fdccd7ad11e4ee8e82ec26162" (without quotes) and use it in the bash script.
Solution
Use jq
to extract the value from the JSON, and command substitution to capture the output of the command:
code=$(curl ... | jq -r '.code')
The -r
(--raw
) prints the string directly instead of quoting it as in a JSON.
Answered By - choroba Answer Checked By - Gilberto Lyons (WPSolving Admin)