samedi 30 mars 2019

Invert if statement with pipes

I want to add a command to my .bash_profile that runs a script if it's not already running. Below is my attempt.

if ps ax | grep reminder.py | grep -v grep;
  echo 'i want to get rid of this line'
then
  python /Users/Jesse/Dropbox/reminder/reminder.py &
fi

I can't figure out the syntax for inverting the if statement.

I tried a bunch of stuff similar to this:

if ! ps ax | grep reminder.py | grep -v grep
then
  python /Users/Jesse/Dropbox/reminder/reminder.py &
fi

None of my attempts were successful.

I'm running on macOS if that's relevant.

Aucun commentaire:

Enregistrer un commentaire