Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!nike!oliveb!hplabs!sdcrdcf!ism780c!dianeh From: dianeh@ism780c.UUCP (Diane Holt) Newsgroups: net.unix,net.unix-wizards Subject: Re: question-- Bourne (and C) SHELL Message-ID: <3589@ism780c.UUCP> Date: Tue, 16-Sep-86 21:36:20 EDT Article-I.D.: ism780c.3589 Posted: Tue Sep 16 21:36:20 1986 Date-Received: Fri, 19-Sep-86 23:08:40 EDT References: <1751@ittatc.ATC.ITT.UUCP> <7028@utzoo.UUCP> <150@humming.UUCP> <6228@sun.uucp> <574@ih1ap.UUCP> Reply-To: dianeh@ism780c.UUCP (Diane Holt) Organization: Interactive Systems Corp., Santa Monica, CA Lines: 50 Xref: mnetor net.unix:5531 net.unix-wizards:7910 In article <574@ih1ap.UUCP> sja@ih1ap.UUCP (Steve Alesch) writes: >In article <6228@sun.uucp>, guy@sun.uucp (Guy Harris) writes: >> > The key thing here is the ability to NOT the value of status. >> > How is this similar thing done in Bourne shell. >> > if ! ls foo >> > then >> > echo foo does not exist >> > fi >> >> Try >> if ls foo >> then >> : >> else >> echo foo does not exist >> fi >> [or] >> if test ! -f foo >> >Correct me if I'm missing something. What's wrong with: > ls foo > if [ $? != 0 ]; then > echo foo does not exist > fi I didn't see the original posting, so I'm not sure exactly what's trying to be done, but my suggestion would be: ls foo || echo "foo does not exist" The || is "OR" -- return "true" from the first command "OR" execute the next one. Double ampersand (&&) is used to check the return from the first command "AND" execute the next one. There is no limit on how many "next" commands there can be or any restrictions on combinations of "OR"s and "AND"s. I use this all the time. P.S. Obviously, this whole example is pretty silly, since 'ls' will output "foo not found", if it doesn't really exist, so echoing that it doesn't is superfluous...but I'm assuming that the command used is just an example and not significant to the original poster's question...if it really *is* significant, then you'd want to redirect the output: ls foo >/dev/null 2>&1... Diane Holt Interactive Systems Corp. Santa Monica, CA {seismo,decvax,cbosgd}!hplabs!sdcrdcf!ism780c!dianeh "But I don't know anything about computers." "Nobody does...but don't you want one for when you do find out?"