Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 537

How to dynamically replace value with jq in bash [duplicate]

$
0
0

I'm trying to get a value from the Json and add it to another field of the same json file. I need to do it in a lot of file so I'm using a loop:

for i in $(find . -name \*.txt); do     valorAPoner=$(cat $i | jq -r .Name);     tmp=$(mktemp);    jq -r '.Authentication.ExternalProvider.LdapUserAndDomain |= "$valorAPoner"' $i  > "$tmp" && mv "$tmp" $i.json; done

But when I open $i.json it shows me:

{"Name": "dsfdsf","FullName": "xxxxx","Authentication": {"ExternalProvider": {"LdapUserAndDomain": "$valorAPoner"

I see the string literal of the variable (valorAPoner) but I need the value of the variable. Do you know how to answer it?

Thanks


Viewing all articles
Browse latest Browse all 537

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>