0

I'm using the jq tool to handle some JSON in bash.
Just one problem, while using this line:

PB_ACL="acl="`echo $IMGREQ | jq -r'.data.acl'` 

Result:

echo $PB_ACL // acl= 

The expected value jq has to filter out is: "acl":"public-read" But it's not working now. I think it has to to with the dash (-) symbol.

How do I escape such incoming string data?

8
  • 1
    Try PB_ACL="acl=$(echo $IMGREQ | jq -r'.data.acl')" (Or use the backticks, just leave it inside the double quotes) Commented Jul 2, 2015 at 20:38
  • The command between the backticks to be processed. (Command Substitution) So Im afraid this ain't gonna work... Commented Jul 2, 2015 at 20:40
  • 1
    I'm not sure I understand your comment but command substitution do occur inside double quotes. Commented Jul 2, 2015 at 20:41
  • Just getting: acl=echo Commented Jul 2, 2015 at 20:43
  • Are you sure you modified your code with the change I made? Commented Jul 2, 2015 at 20:48

1 Answer 1

2

Missed a space:

PB_ACL="acl="`echo $IMGREQ | jq -r '.data.acl'` ^ 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.