Search code examples
bashfor-loopcommand-linebackground-processexecute

bash script, execute command line and keep going the next for loop


Is it possible to run a command in a for loop without waiting for that command ended, while keeping going to the next iteration?

Because I have to send multi-files at the same time asap via many ssh connections, therefore I couldn't wait until the command ended one by one.

Maybe is it related to something like 'xterm' or 'gnome-terminal'?


Solution

  • Yes, you can execute the command in background by adding & at its end.

    So the syntax looks like programName [arguments] & (at least for bourne compatible shells)