I am trying to run a.out lot of times from command line, but am not able to start the processes in background because bash treats it as a syntax error.
for f in `seq 20`; do ./a.out&; done //incorrect syntax for bash near '&'
How can I place & on command line so that bash doesn't complain, and I am allowed to run these processes in background, so that I can generate load on the system.
P.S: I don't want to break it into mult开发者_开发百科iple lines.
This works:
for f in `seq 20`; do ./a.out& done
& terminates a command just like ; or &&, ||, |.
This means that bash expects a command between & and ; but can't find one. Hence the error.
& is a command terminator as well as ; ; do not use both.
And use bash syntax instead of using seq, which is not available on all Unix systems.
for f in {1..20} ; do ./a.out& done
Remove the ; after a.out:
for f in `seq 20`; do ./a.out& done
Break that into multiple lines or remove the ; after the &
加载中,请稍侯......
精彩评论