How do I ask "if NOT" in shell?

paul kirkaas kirkaas at oahu.cs.ucla.edu
Mon Oct 23 09:13:27 AEST 1989


How can one say "if not" in a shellscript; that is, execute the body of
the "then" only if the argument of "if" returns a non-zero exit status?

I would like something like:

if ! TESTCOMMAND
then
	BODY
fi

Stupid question?   Trivial answer?   I hope so.  Thanks.


Paul Kirkaas
kirkaas at cs.ucla.edu



More information about the Comp.unix.questions mailing list