How to logically negate the return value of a command?

Colin Watson cjwatson at ubuntu.com
Wed Sep 24 15:52:38 UTC 2014


On Mon, Sep 22, 2014 at 07:04:57PM +0100, Chris Green wrote:
> 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.

Match exec "! ping -c 1 hostname"

-- 
Colin Watson                                       [cjwatson at ubuntu.com]




More information about the ubuntu-users mailing list