linux - Negate a command return value condition in bash -


i tried negate following condition:

if pgrep "$name" >> /dev/null;     # stuff fi 

at first tried syntax, can found in thread.

if ! [[ pgrep "$name" >> /dev/null ]];     # stuff fi 

while syntax perfect if want compare variables , literals, in case fail following error:

watchdog: line 58: conditional binary operator expected

watchdog: line 58: syntax error near `"$name"'

watchdog: line 58: ` if ! [[ pgrep "$name" >> /dev/null ]]; then'

simply use ! to check if failed:

if ! pgrep "$name" >> /dev/null;     # stuff fi 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -