I received the error:

bash: syntax error near unexpected token `;'

due to the following command:

evince foo.pdf bar.pdf &; emacs foo.tex &

I is it illegal to separate commands with ; when using & to background a job? Or is there another reason this didn't work?

Thank you.

link|improve this question

feedback

2 Answers

up vote 5 down vote accepted

You don't need the semicolon. After it's sent to the background it's free to get another command.

evince foo.pdf bar.pdf & emacs foo.tex &
link|improve this answer
feedback

No, it's just confused and can't work out quite what you mean.

You need to group the & with the command that you want to put in the background:

$ (evince foo.pdf bar.pdf &); emacs foo.tex &

That works fine. Even more explicit would be:

$ (evince foo.pdf bar.pdf &); (emacs foo.tex &)

Especially if you then wanted to chain more commands after the end as well.

link|improve this answer
Thanks for the input. I think I see why it balked. – DQdlM Apr 11 '11 at 14:42
feedback

Your Answer

 
or
required, but never shown

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