testing if a file is present
Jon H. LaBadie
jon at jonlab.UUCP
Sat Dec 1 06:26:50 AEST 1990
In article <2549 at root44.co.uk>, gwc at root.co.uk (Geoff Clare) writes:
>
> test -f file -o -d file -o -c file -o -b file -o -p file
>
> but I don't count that as "equivalent"!
>
OK, granted, but how about the nearly equivalent
test ! -f file
It will be true when you want a regular file of the indicated name
and false if said file does not exist or is a type other than regular.
Another possibility not mentioned in this thread (and with its own
limitations) is test -s file. For this to be true, the file must
exist and have some content (i.e. not an empty file).
Jon
--
Jon LaBadie
{att, princeton, bcr, attmail!auxnj}!jonlab!jon
More information about the Comp.unix.shell
mailing list