My goal is to do
filename=user2.json
userJson=${cat ${filename} | jq}
This obviously don't work.
According to this answer, this should work (but it doesn't):
filename=user2.json
eval "userJson=\${cat $filename | jq}"
Error: ${cat user2.json | jq}: bad substitution
cat user2.json | jq
works fine on its own
Here are other combinations I tried that didn't work:
1.
filename=user2.json
eval "userJson=\${cat $(filename) | jq}"
Error: ${cat | jq}: bad substitution
2.
filename=user2.json
eval "userJson=\${cat '${filename}' | jq}"
Error: ${cat 'user2.json' | jq}: bad substitution
userJson=$(cat "${filename}" | jq .)
– sseLtaH Aug 28 '22 at 10:42