How to write a for loop which runs an asynchronous command in each iteration?
Drop the ;
:
for i in {1..8}; do sleep 100 & done
&
separates commands, so the ;
is extraneous (and the shell expects something between &
and ;
).
Group your do
actions in curly brackets:
for i in {1..8}; do { sleep 100 & }; done
Easy to understand for you as well as for Bash!