Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!pyrltd!root44!gwc From: gwc@root.co.uk (Geoff Clare) Newsgroups: comp.unix.shell Subject: Re: testing if a file is present Message-ID: <2549@root44.co.uk> Date: 27 Nov 90 13:55:50 GMT References: <1990Nov21.155149.3505@informix.com> Distribution: comp.unix Organization: UniSoft Ltd., London, England Lines: 19 In <1990Nov21.155149.3505@informix.com> dberg@informix.com (David I. Berg) writes: >if (-f filename) will return true if the file exists, false if not. Wrong. It will return true if the file exists AND IS A PLAIN FILE. To test for existence only use -e. This is one place where csh has an advantage over Bourne shell. There is no equivalent way with the Bourne shell "test" command to test for existence without also testing for a specific file type or access mode. OK, so you can do it with test -f file -o -d file -o -c file -o -b file -o -p file but I don't count that as "equivalent"! -- Geoff Clare (Dumb American mailers: ...!uunet!root.co.uk!gwc) UniSoft Limited, Hayne Street, London EC1A 9HH, England. Tel: +44-71-315-6600