Here's my script:
if [[ $(jq '.haystack | index("needle")' /etc/xyz/daemon.json) = \0 ]] ; then
    jq '.haystack += ["needle"]' /etc/xyz/daemon.json > daemon.json
    mv -f daemon.json /etc/xyz/daemon.json
fi
I want to add needle to haystack array in a daemon.json file. However the problem is in the if construct of the shell. When I test the condition with echo True/False the terminal does show True or False based on the command in the condition. However, I cannot do any other command, such as a simple ls or mkdir. I execute the command from terminal, not saving into a bash file. Newline doesn't seem to need \.
I'm completely new to Linux terminal, is there something I'm missing here? Thanks!
 
    