Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!cbosgd!ihnp4!cuae2!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: net.unix,net.unix-wizards Subject: Re: question-- Bourne (and C) SHELL Message-ID: <1139@ttrdc.UUCP> Date: Sun, 17-Aug-86 14:31:50 EDT Article-I.D.: ttrdc.1139 Posted: Sun Aug 17 14:31:50 1986 Date-Received: Tue, 19-Aug-86 08:22:20 EDT References: <1751@ittatc.ATC.ITT.UUCP> <7028@utzoo.UUCP> <150@humming.UUCP> Organization: AT&T, Computer Systems Division, Skokie, IL Lines: 41 Xref: watmath net.unix:8933 net.unix-wizards:19264 In article <150@humming.UUCP>, arturo@humming.UUCP (Arturo Perez) writes: >In the csh you can do something like > >ls foo >if (! $status) then > echo "foo exists" >endif > >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 To follow your example literally: ls foo if test $? -ne 0 # or, "if [ $? -ne 0 ]" is supported by modern /bin/sh's then echo foo does not exist fi Of course, there are other ways to check for nonexistence of foo, e.g.: if [ ! -f foo -a ! -d foo -a ! -p foo -a ! -c foo -a ! -b foo ] # foo is not a file, a directory, a pipe, a character special device, or a # block special device which though "wordier" does not require the spawning of another process presuming that "test" is a builtin in your shell. -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, go for it! allegra,ulysses,vax135}!ttrdc!levy