I am trying to open 2 separate windows/instances of emacs from the terminal in a single command. I have tried:

emacs &; emacs &

(error: bash:syntax error near unexpected token ; and

emacs & && emacs &

(error: bash:syntax error near unexpected token && but both ways produce errors. How can I produce in a single command 2 windows of emacs to emerge?

  • Rather than saying the attempts "produce errors", please show the actual errors. The messages you see may be helpful in diagnosing what is going awry. – DopeGhoti Sep 13 '18 at 21:45

You need only single separator between commands: ; or & or && etc, so try

emacs & emacs &

If you run emacs &; emacs & then you start emacs in the background, and then run ; without any command so bash claims it doesn't expect this separator there (syntax error near unexpected token ;).

Similar error you will get by just running bare ;:

bash$ > ;
bash: syntax error near unexpected token `;'

Not all shell behaves like that, for example in zsh you can even do

zsh$> ; ; ls; ; ls&; ls&; ; ls &; ;

without any problems (but not ;; without space in-between) as it is a separator on itself, used in case statement).

The other thing you tried, emacs & && emacs &, is even worse as second command (after &&) should be run only if the first one ended successfully (this is what && does). But, since we run the first command in the background shell doesn't wait for its finish, so that condition doesn't make much sense. Once again: use just single separator between commands, either command1 & command2 or eventually command1 && command2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.