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
Post a Comment