Article View: comp.unix.shell
Article #1844Re: testing if a file is present
From: Geoff Clare
Date: Tue, 27 Nov 1990 13:55
Date: Tue, 27 Nov 1990 13:55
19 lines
1256 bytes
1256 bytes
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 <gwc@root.co.uk> (Dumb American mailers: ...!uunet!root.co.uk!gwc) UniSoft Limited, Hayne Street, London EC1A 9HH, England. Tel: +44-71-315-6600
Technical Details
Message-ID:
<2549@root44.co.uk>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!pyrltd!root44!gwcReferences:
<ger.659126250@prisma> <1990Nov21.155149.3505@informix.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <ger.659126250@prisma> <1990Nov21.155149.3505@informix.com> Distribution: comp.unix Organization: UniSoft Ltd., London, England Lines: 19