Article View: comp.unix.shell
Article #1874Re: testing if a file is present
From: Leslie Mikesell
Date: Wed, 28 Nov 1990 15:18
Date: Wed, 28 Nov 1990 15:18
17 lines
1138 bytes
1138 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 Ah, the error message is the real problem here - just throw it away! mv old new 2>/dev/null Note of course that you also lose "real" error messages with this approach. However, also keep in mind that no method of testing before the move is atomic with the mv itself and thus will fail with multiple concurrent processes. Les Mikesell les@chinet.chi.il.us
Technical Details
Message-ID:
<1990Nov28.151858.26541@chinet.chi.il.us>Path:
arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!gargoyle!chinet!lesReferences:
<ger.659126250@prisma>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!gargoyle!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.unix.shell Subject: Re: testing if a file is present Message-ID: <1990Nov28.151858.26541@chinet.chi.il.us> Date: 28 Nov 90 15:18:58 GMT References: <ger.659126250@prisma> Distribution: comp.unix Organization: Chinet - Public Access UNIX Lines: 17