Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!wuarchive!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!hplabs!hpl-opus!steinbac From: steinbac@hpl-opus.HP.COM (Gunter Steinbach) Newsgroups: comp.unix.questions Subject: Re: How do I ask "if NOT" in shell? Message-ID: <63720012@hpl-opus.HP.COM> Date: 26 Oct 89 17:32:11 GMT References: <28381@shemp.CS.UCLA.EDU> Organization: HP Labs, High Speed Electronics Dept., Palo Alto, CA Lines: 21 From article <1989Oct26.041244.28325@sobmips.UUCP>, by roe@sobmips.UUCP (r.peterson): > I tried this: > true && { > echo true > } || { > echo false > } > and it functions fine. Change true && to false && and it prints false > correctly as well. Neato! I like it. But... You have to be careful with nontrivial commands in the first command group (the if true group): Add a "false" command after the first echo in your example, and it prints out both "true" and "false" - not at all what you wanted. So it is not a true "else" that only refers to the original test. Guenter Steinbach | hplabs!gunter_steinbach | gunter_steinbach@hplabs.hp.com