Article View: comp.unix.shell
Article #1839Re: testing if a file is present
From: Jon H. LaBadie
Date: Tue, 27 Nov 1990 07:56
Date: Tue, 27 Nov 1990 07:56
35 lines
1509 bytes
1509 bytes
> In article <ger.659126250@prisma> ger@prisma.cv.ruu.nl (Ger Timmens) writes:
> Can anybody tell me how I can verify whether a file exists or not ?
> I want to move files and only when they exist ! mv "file" gives an
> error message if "file" not exists
A number of poster have responded to Ger's posting by suggesting the
-f option of test (builtin or separate executable). Most claimed this
option tests if the file exists and suggest that the manual be read.
They should read the manual which says:
-f file true if file exists AND is a regular file
(emphasis mine)
I.e., the -f is a filetype/existance test. If a directory foobar
exists, test -f foobar is false; test -d foobar is true.
There are a number of filetype/existance options to test:
-f regular files
-d directory files
-b block special files
-c character special files
-p named pipe files (fifo's)
and on some systems:
-???? symbolic link files
Jon
--
Jon LaBadie
{att, princeton, bcr, attmail!auxnj}!jonlab!jon
Technical Details
Message-ID:
<887@jonlab.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!wuarchive!udel!princeton!jonlab!jonReferences:
<ger.659126250@prisma>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!wuarchive!udel!princeton!jonlab!jon From: jon@jonlab.UUCP (Jon H. LaBadie) Newsgroups: comp.unix.shell Subject: Re: testing if a file is present Summary: posters suggesting RTM should also RTM themselves Message-ID: <887@jonlab.UUCP> Date: 27 Nov 90 07:56:41 GMT References: <ger.659126250@prisma> Distribution: comp.unix Organization: 4455 Province Line Rd., Princeton, NJ 08540 Lines: 35