How to logically negate the return value of a command?

Nathan Dorfman na at rtfm.net
Tue Sep 23 15:34:41 UTC 2014


On Mon, Sep 22, 2014 at 2:04 PM, Chris Green <cl at isbd.net> wrote:
> However this doesn't work of course.  Is there any easy way (i.e. an
> executable command) which will logically not the value that ping
> returns?  I know I could write a little script that does the job but
> if can do it without I'd be happier.


There's probably a nicer way to do it, but this should work:

    ping -c1 hostname; test "$?" -ne 0

-nd.

> --
> Chris Green




More information about the ubuntu-users mailing list