[英]JQ argument error in bash script
我有一個JQ查詢問題:
max=$(script) <-- (return integer)
jq -r ".notifiestext | map(select(.read==false))" temp_notif |
jq --arg foo "$max" "map(select(.id<$foo))"
我收到以下錯誤:
jq: error: syntax error, unexpected ')' (Unix shell quoting issues?) at <top-level>, line 1: map(select(.id<))
“ .id”參數是整數
有什么辦法嗎?
您需要對$foo
的$
進行轉義,以便外殼程序甚至在jq
運行之前都不會嘗試將其擴展為參數。
jq -r ".notifiestext | map(select(.read==false))" temp_notif |
jq --arg foo "$max" "map(select(.id<\$foo))"
最好對jq
過濾器使用單引號。
jq -r '.notifiestext | map(select(.read==false))' temp_notif |
jq --arg foo "$max" 'map(select(.id<$foo))'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.