Skip to content

Instantly share code, notes, and snippets.

@akoserwal
Last active July 15, 2022 06:37
Show Gist options
  • Save akoserwal/a8ead4cfbc4b978533839bbc56ed6f29 to your computer and use it in GitHub Desktop.
Save akoserwal/a8ead4cfbc4b978533839bbc56ed6f29 to your computer and use it in GitHub Desktop.
parsing-key-value-with-jq
dataseturl=https://gist.githubusercontent.com/akoserwal/4817cccbb53262056405bcc1eef37443/raw/7af7a0a6a60b5e2b8699f0c6e779c236e8f1055d/sample-output.json
map=$(curl $dataseturl | jq -r '.[]')
echo $map
echo $map | jq -r '[.id, .name, .value] | @csv'| tr -d '"' | \
while IFS=, read -r id name value ; do
echo $id:$value
if [[ $name =~ test* ]] ;
then
echo "$id,$name,$value" >> generated.csv
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment