Shell – Combine parallel and sequential commands

gnu-parallelparallelismshell

1. Summary

I don't understand, how I can combine parallel and sequential commands in Linux.


2. Expected behavior

Pseudocode:

pip install pipenv sequential pipenv install --dev

parallel task

npm install -g grunt-cli sequential npm install

Windows batch working equivalent:

start cmd /C "pip install pipenv & pipenv install --dev"
start cmd /C "npm install -g grunt-cli & npm install"

3. Not helped

  1. I don't think, that & and wait can solve this problem, see rsaw comment.
  2. I read, that GNU parallel — is better way for parallel tasks, but I can't find, which syntax I need to use in GNU parallel, that solve this task.
  3. I try parallelshell:

    parallelshell "pip install pipenv && pipenv install --dev" "npm install -g grunt-cli && npm install"
    

    Full .sh file:

    git clone --depth 1 https://github.com/Kristinita/KristinitaPelican
    wait
    cd KristinitaPelican
    wait
    parallelshell "pip install pipenv && pipenv install --dev" "npm install -g grunt-cli && npm install"
    

    But at first pipenv install --dev command run for me, then npm install. It sequential, not parallel.

Best Answer

Simply with GNU parallel:

parallel ::: 'pip install pipenv && pipenv install --dev' \
             'npm install -g grunt-cli && npm install'
Related Question