How to logically negate the return value of a command?
Kevin O'Gorman
kogorman at gmail.com
Tue Sep 23 15:46:53 UTC 2014
or
if ping -c1 hostname ; then false; else true; fi
You may or may not want to redirect the output of ping to /dev/null
On Tue, Sep 23, 2014 at 8:34 AM, Nathan Dorfman <na at rtfm.net> wrote:
> 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
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
--
Kevin O'Gorman
programmer, n. an organism that transmutes caffeine into software.
Please consider the environment before printing this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20140923/7bbb632d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 441 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20140923/7bbb632d/attachment.gif>
More information about the ubuntu-users
mailing list