Last active
September 27, 2021 20:42
-
-
Save arbakker/4e0eaf8251b2f96c5f584b69630e094c to your computer and use it in GitHub Desktop.
Add property to item in array where condition jq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| test='[ | |
| {"foo": "parrot"}, | |
| {"foo": "fjords"} | |
| ]' | |
| jq "[.[] | select(.foo != \"parrot\")] + [.[] | select(.foo == \"parrot\") + {bar: \"ex-parrot\"}]" <<< $test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment