0

I know I can use & at the end of a command to make it run in background and && to connect multiple commands at the same line. However, when I use them together it seems not work. Below is an example.

json-server --watch db.json & && python -m http.server 7777

The error message is:

bash: syntax error near unexpected token `&&'

Is it possible to make them work together? Thanks.

5

It seems you want this

json-server --watch db.json & python -m http.server 7777

The && is not to connect multiple commands at the same line, that is ;. The && is a logical AND. You can't use an AND if you don't wait for the command to exit.

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.