testing if a file is present

Leslie Mikesell les at chinet.chi.il.us
Thu Nov 29 02:18:58 AEST 1990


In article <ger.659126250 at prisma> ger at 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 at chinet.chi.il.us



More information about the Comp.unix.shell mailing list