Json bash脚本中的JQ参数错误
我对JQ查询有问题:Json bash脚本中的JQ参数错误,json,bash,jq,Json,Bash,Jq,我对JQ查询有问题: max=$(script) <-- (return integer) jq -r ".notifiestext | map(select(.read==false))" temp_notif | jq --arg foo "$max" "map(select(.id<$foo))" max=$(script)您需要为$foo转义$,以便shell在jq运行之前不会尝试将其扩展为参数 jq -r ".notifiestext | map(select(.r
max=$(script) <-- (return integer)
jq -r ".notifiestext | map(select(.read==false))" temp_notif |
jq --arg foo "$max" "map(select(.id<$foo))"
max=$(script)您需要为$foo
转义$
,以便shell在jq
运行之前不会尝试将其扩展为参数
jq -r ".notifiestext | map(select(.read==false))" temp_notif |
jq --arg foo "$max" "map(select(.id<\$foo))"
您需要为$foo
转义$
,以便shell在jq
运行之前不会尝试将其作为参数展开
jq -r ".notifiestext | map(select(.read==false))" temp_notif |
jq --arg foo "$max" "map(select(.id<\$foo))"
最好直接提问,而不是添加评论。另外,对代码块使用缩进,而不是多行倒勾。最好直接提问,而不是添加注释。另外,对代码块使用缩进而不是多行倒勾。还应该注意,对jq的第二次调用完全没有必要。它可以用一个电话来写。老实说,我甚至从来没有看过两个电话的实际用途。还应该注意的是,第二个打给jq的电话是完全没有必要的。它可以用一个电话来写。老实说,我甚至从来没有看过这两个电话实际上在做什么。
jq -r '.notifiestext | map(select(.read==false))' temp_notif |
jq --arg foo "$max" 'map(select(.id<$foo))'