I need to execute
node simulator.js 1 &
node simulator.js 2 &
node simulator.js 3 &
node simulator.js 4 &
node simulator.js 5 &
...
node simulator.js 10 &
So, I was trying out the shell script for loop to do this, but I am getting this error.
user@host$ for i in {1..10}; do node simulator.js "${i}" &; done
bash: syntax error near unexpected token `;'
I am pretty new to Shell scripts, might be a very small thing here, can someone help figure it out?
UPDATE
the issue with not with the for loop,
its with the &, the error persists even if I do
for i in {1..10}; do node simulator.js 1 &; done
Problem is semi-colon after &.
This should work
for i in {1..10}; do node simulator.js 1 & done
This will fork 10 subshell processes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With