0

I'm trying to run commands in parallel. But these commands need to be run in different directories. How can I achieve this? Can I do something like this:

parallel ::: 'cd platform1 && npm install && npm run build-all'
'cd platform2 && npm install && npm run build-prod'
Tollef Fog Heen
  • 712
  • 3
  • 10
masterforker
  • 103
  • 2

1 Answers1

0
#!/bin/sh
(cd platform1 && npm install && npm run build-all && touch flag.1) &
(cd platform2 && npm install && npm run build-prod && touch flag.2) &

while [ !( -f flag.1 -a -f flag.2 ) ]
do sleep 5
done

# All the rest code

####

Commands placed inside round brackets (or backticks) are launched inside subshell that is launched in background because of trailing &

Kondybas
  • 6,964
  • 2
  • 20
  • 24