Article View: comp.unix.shell
Article #1813Re: testing if a file is present
From: Wm E. Davidsen Jr
Date: Fri, 23 Nov 1990 03:07
Date: Fri, 23 Nov 1990 03:07
26 lines
1430 bytes
1430 bytes
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
--
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
"Stupidity, like virtue, is its own reward" -me
Technical Details
Message-ID:
<2356@sixhub.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!crdgw1!sixhub!davidsenReferences:
<ger.659126250@prisma> <1990Nov21.191638.19469@athena.mit.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!crdgw1!sixhub!davidsen From: davidsen@sixhub.UUCP (Wm E. Davidsen Jr) Newsgroups: comp.unix.shell Subject: Re: testing if a file is present Message-ID: <2356@sixhub.UUCP> Date: 23 Nov 90 03:07:29 GMT References: <ger.659126250@prisma> <1990Nov21.191638.19469@athena.mit.edu> Reply-To: davidsen@sixhub.UUCP (bill davidsen) Distribution: comp.unix Organization: *IX Public Access UNIX, Schenectady NY Lines: 26