Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json bash脚本中的JQ参数错误_Json_Bash_Jq - Fatal编程技术网

Json bash脚本中的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

我对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(.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))'