I'm trying to create a shell script that reads and writes to certain text files on two second intervals. When I run the script by itself (without watch), it works perfectly fine. However, when I run it using watch -n 2 ./feedcmd.sh
, I'm given this error: ./feedcmd.sh: 2: ./feedcmd.sh: Syntax error: "(" unexpected
.
I've tried adding an extra pair of parentheses around that phrase, but still no luck.
Here's my shell script:
$(tmux capture-pane -t "$tes3-server" -pS 32768 > one.txt)
output=$(comm -23 <(sort one.txt) <(sort two.txt))
len=`expr "$output" : '.*'`
if [ "$len" -gt 0 ]; then
$(echo "$output" > fin.txt)
$(cat one.txt > two.txt)
$(echo 0 > done.d)
fi
echo "done"
watch
is likely executing it using /bin/sh, which doesn't support process substitutions like<(command)
– steeldriver Mar 07 '21 at 04:18