How can I run a Bash command for every JSON object in a JSON array using jq
? So far I have this:
cat credentials.json | jq -r \'.[] | .user, .date, .
Your best bet is probably to output each record in something like TSV format, then read that from a shell loop.
jq -r '.[]|[.user, .date, .email] | @tsv' |
while IFS=$'\t' read -r user date email; do
mycommand -u "$user" -d "$date" -e "$email"
done
jq
itself doesn't have anything like a system
call to run an external command from within a filter, although it seems that they are working on it.