I know I can run a program in the background using &
.
command &
However, I want to run multiple commands, and cd
into a different directory while they are running.
The multiple commands will still rely on the directory I was previously in.
I've tried the following, but it only runs the last command in the background:
command1 && command2 &
Doing this gives a parse error:
command1 & && command2 &
It's important that command1
finishes before command2
,
so I don't think the following would guarantee that:
command1 &; command2 &;
I'm not tied to any specific shell.
;
isn't needed after&
, it can separate commands itself:command1 & command2
. – choroba May 4 '16 at 14:59;
– Gilles 'SO- stop being evil' May 4 '16 at 22:59