🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1848

Re: testing if a file is present

#1848
From: Don Bolton
Date: Tue, 27 Nov 1990 22:50
42 lines
1747 bytes
In article <2356@sixhub.UUCP> davidsen@sixhub.UUCP (bill davidsen) writes:
>In article <1990Nov21.191638.19469@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes:
>
>| In sh, with either a test built-in named "[" or a link in your filesystem
>| called "[" pointing to the test program:
>| 
>| 	if [ -r filename ]; then
>| 		... stuff if filename exists ...
>| 	fi
>| 
>| Some versions of test allow "-e" to test for existence, instead of "-r" to
>| test for existence and readibility, but mine doesn't, so I use "-r" instead of
>| "-e" above.  In sh without "[":
>| 
>| 	if test -r filename; then
>| 		... stuff if filename exists
>| 	fi
>
>  Close but not correct.
>	-f is there a file
>	-r is it readable
>	-x is it executable

	-s file has nonzero length

>-- 
>bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
>    sysop *IX BBS and Public Access UNIX
>    moderator of comp.binaries.ibm.pc and 80386 mailing list

if [ -s $USER.IQ ]
   then 
       echo "Proceed..."
       read chore
       etc etc
   else
       echo "Stupidity, like virtue, is its own reward"
       exit 0
fi


There, now your .sig is more fitting :-)
Technical Details
Message-ID: <47309@sequent.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!mit-eddie!uw-beaver!zephyr.ens.tek.com!tektronix!sequent!lugnut
References: <ger.659126250@prisma> <1990Nov21.191638.19469@athena.mit.edu> <2356@sixhub.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!mit-eddie!uw-beaver!zephyr.ens.tek.com!tektronix!sequent!lugnut
From: lugnut@sequent.UUCP (Don Bolton)
Newsgroups: comp.unix.shell
Subject: Re: testing if a file is present
Message-ID: <47309@sequent.UUCP>
Date: 27 Nov 90 22:50:05 GMT
References: <ger.659126250@prisma> <1990Nov21.191638.19469@athena.mit.edu> <2356@sixhub.UUCP>
Reply-To: lugnut@sequent.UUCP (Don Bolton)
Distribution: comp.unix
Organization: Sequent Computer Systems, Inc
Lines: 42