https://stackoverflow.com/questions/29396154/jq-setdiff-of-two-arrays
1.
echo -n '{"all":["A","B","C","ABC"],"some":["B","C"]}' | jq '. as $d | .all | del(.[ indices($d.some[])[] ])'
2.
array1='["A","B","C","ABC"]' array2='["B","C"]' jq -n --argjson array1 "$array1" --argjson array2 "$array2" '$array1-$array2' jq -n --argjson array1 "$array1" --argjson array2 "$array2" '{"all": $array1,"some":$array2} | .all-.some'
3.
echo -n '{"all":["A","B","C","ABC"],"some":["B","C"]}' | jq ' . as $d | .all | [indices($d.some[])[]] as $found | del(.[ $found[] ]) | "all", $d.all, "some", $d.some, "removing indices", $found, "result", .‘
标签:shell,--,array2,array1,some,jq,差集,数组,argjson From: https://www.cnblogs.com/shaohef/p/17475988.html