How to logically negate the return value of a command?

Chris Green cl at isbd.net
Mon Sep 22 18:04:57 UTC 2014


I want to use ping to detect if a machine is available locally on a
LAN as a test for a 'match exec' in ~/.ssh/config.

The trouble is that I need to logically negate the return value, i.e.
I want to have something like:-

    match exec "not ping -c 1 hostname"

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.

-- 
Chris Green




More information about the ubuntu-users mailing list