I'm trying to make a bash script that loops through a file that contains a list of files (so it goes through each one of these files). While the files are open, I want to use another program (jq) to extract the values from the key value pair of the JSON files. Here's what I'm working with so far, kept pretty basic so I can try to figure out where I'm going wrong. I'm not concerned about the jq command, I've had it working where I am able to loop through all the files and pull out the values of a single key, but this ends up being extremely tedious because I have to manually change it for each key.
TL;DR: 'master' is the file that contains the full path of each one of the JSON files I want to open. 'key.txt' is a file that contains all of the possible keys within these JSON files. $KEY is the syntax for jq to search through the open file for that specific key and return the value of that key. I want to open up a file in the master list, loop through all the possible keys, and return the values of these keys into a text file called 'list.txt'.
Any help would be greatly appreciated.
#!/bin/bash master="path/masterlist.txt" while read master do for KEY in 'key.txt' do jq '. .'$KEY'' $f echo $KEY done >> list.txt echo $master done < list.txt