You didn't provide a reproducible example, but I think I managed to make one for testing:
watch -n1 "paste <(seq -w 1000 | shuf -n '10' ) <(seq -w 1000 | shuf -n '10')"
output a similar error:
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `paste <(seq -w 1000 | shuf -n '10' ) <(seq -w 1000 | shuf -n '1
0')'
To solve this problem in a simpler way, we can change sh -c
for bash -c
:
watch -n1 -x bash -c 'paste <(seq -w 1000 | shuf -n "10" ) <(seq -w 1000 | shuf -n "10")'
From the watch
manual:
-x, --exec
Pass command to exec(2) instead of sh -c which reduces the need to
use extra quoting to get the desired effect.
If you need maintain the apostrophes from the original commandline, you can escape then too:
watch -e -n1 -x bash -c 'paste <(seq -w 1000 | shuf -n '\''10'\'' ) <(seq -w 1000 | shuf -n '\''10'\'')'