Would like to be able to pass multiple arguments into a jq statement like so:
jq --arg ARG1 ${var1} ARG2 ${var2} '.$ARG1[$ARG2 | tonumber].width'
@rclod - You can pass in as many named arguments as you like by repeating the "--arg NAME VALUE" pattern.
thanks! I had tried that earlier, but had forgotten to put quotes around my variable call.
This ended up working as expected:
jq --arg ARG1 ${var1} --arg ARG2 ${var2} '."$ARG1"[$ARG2 | tonumber].width'
@rclod - Because of variations between different versions of jq, it's sometimes simpler just to use the form .[s] instead of .s. Or in your case: .[$ARG1][$ARG2]
You're right, the quotes didn't end up working, but the brackets did.
jq --arg ARG1 ${var1} --arg ARG2 ${var2} '.[$ARG1][$ARG2 | tonumber].width'
Most helpful comment
You're right, the quotes didn't end up working, but the brackets did.
jq --arg ARG1 ${var1} --arg ARG2 ${var2} '.[$ARG1][$ARG2 | tonumber].width'