Path: 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: Distribution: comp.unix Organization: 4455 Province Line Rd., Princeton, NJ 08540 Lines: 35 > In article 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