1
I have a JSON
in an archive nomes.txt
.
the JSON
is :
{"p": { "nome": ["josé","Maria", "carlos","Artur"] }}
I want to play the value of his query in a variable.
Show result works fine :
#!/bin/bash
ns=`cat nomes.txt`
echo $ns
for ((i=0; i<=4; i++))
do
echo $ns | jq -r ".p | .nome[$i]"
done
But when I try to do something more elaborate I can’t.
I want to play the value of JSON
captured in variable but will not .
#!/bin/bash
ns=`cat nomes.txt`
echo $ns
for ((i=0; i<=4; i++))
do
aux=$ns | jq -r ".p | .nome[$i]"
echo "O nome $i é $aux"
done
The value of $aux
is void.
How can I transfer the value to the variable aux
?