I have a json response as shown below :
[
{"id":10,
"list_file":["/var/a.txt",
"/dev/b.txt"]}
]
I need to extract values of list_file and store it shell variable as an array. I tried doing it looping through and reading the values.
#!/bin/bash
x=()
while read -r value
do
#echo "$value"
x+=("$value")
done < <(jq -r '.[] | .list_file' input.json)
But the extracted values in the array contains quotes, brackets and comma too.
[
"/var/a.txt",
"/dev/b.txt"
]
Could you please help me modify the code so that the array contains only the entries /var/a.txt and /dev/b.txt. Also, I tried readarray and map, but they won't work on Mac Osx. Any help would be really appreciated.