Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!van-bc!twg!bill From: bill@twg.bc.ca (Bill Irwin) Newsgroups: comp.unix.shell Subject: Re: testing if a file is present Message-ID: <332@twg.bc.ca> Date: 21 Nov 90 23:02:25 GMT References: Distribution: comp.unix Organization: The Westrheim Group, Vancouver, B.C., Canada Lines: 28 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 Try this: if [ -f file_name ] then mv file_name /new/destination/file_name fi The "-f" tests for the existence of the file. There are other options: -x is the file executable -r is the file readable -s does the file have anything in it (greater than zero bytes) There are others too. Check your manual under "sh". The options should be listed. -- Bill Irwin - The Westrheim Group - Vancouver, BC, Canada ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uunet!van-bc!twg!bill (604) 431-9600 (voice) | UNIX Systems bill@twg.bc.ca (604) 430-4329 (fax) | Integration