Home > database >  Bash if statement with command terminated by the control operator ampersand &
Bash if statement with command terminated by the control operator ampersand &

Time:09-29

How to use a background command in an if statement?

Here is a minimum step to reproduce:

$ if [[ $(uname -s ) == Linux ]] ; then gedit & ; fi
bash: syntax error near unexpected token `;'

CodePudding user response:

When using & you don't need the ; anymore.

if [[ $(uname -s ) == Linux ]] ; then gedit & fi
  • Related