Bash: syntax error near unexpected token `;'
From Brandonhutchinson.com
(Difference between revisions)
(New page: Trying to background a command within a shell loop? e.g., # '''for VAR in 1 2 3 ; do ''run_program'' $VAR & ; done''' bash: syntax error near unexpected token `;' The reason is explain...) |
|||
| Line 1: | Line 1: | ||
| - | Trying to background a command within a shell loop? e.g., | + | Trying to background a command within a shell loop? I was when I received this error. |
| + | |||
| + | e.g., | ||
# '''for VAR in 1 2 3 ; do ''run_program'' $VAR & ; done''' | # '''for VAR in 1 2 3 ; do ''run_program'' $VAR & ; done''' | ||
Current revision
Trying to background a command within a shell loop? I was when I received this error.
e.g.,
# for VAR in 1 2 3 ; do run_program $VAR & ; done bash: syntax error near unexpected token `;'
The reason is explained here. Both & and ; are line terminators; you only need to specify & before done.
e.g.,
# for VAR in 1 2 3 ; do program $VAR & done [1] 7810 [2] 7811 [3] 7812
