Last active
March 24, 2019 13:47
-
-
Save itayadler/6df7e91d5e36a4c1cc2986720c5bee96 to your computer and use it in GitHub Desktop.
jq rewrite object example and print the top level object
This file contains 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
#!/bin/sh | |
set -e | |
result=$(cat $1 | jq --arg examplekey 'examplevalue' '.dependencies |= {"newkey": $examplekey} + .') | |
echo $result | jq . | cat > $1 | |
#for a given object with key 'dependencies', this will add to the object the key "newkey" with value "examplevalue" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment