testing if a file is present
Don Bolton
lugnut at sequent.UUCP
Wed Nov 28 09:50:05 AEST 1990
In article <2356 at sixhub.UUCP> davidsen at sixhub.UUCP (bill davidsen) writes:
>In article <1990Nov21.191638.19469 at athena.mit.edu> jik at 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 at 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 :-)
More information about the Comp.unix.shell
mailing list