question-- Bourne (and C) SHELL

Ihnat ignatz at aicchi.UUCP
Fri Aug 22 17:48:07 AEST 1986


There may be more elegant ways--it's sometimes tough to be elegant at 2:50
AM--but certainly, for filename FILE

	ls FILE >/dev/null 2>/dev/null

	if [ ! $? ]
	then
		<whatever negated thingies you want>
	fi;

works.  (As we all know, $? is the return code from the last executed command.)
However, if just testing existence, how about

	if [ -f FILE ]
	then
		<etc>
	fi;

Look at test(1); it's got a lot of nifty cases you can test...
-- 
	Dave Ihnat
	Analysts International Corporation
	(312) 882-4673
	ihnp4!aicchi!ignatz || ihnp4!homebru!ignatz



More information about the Comp.unix mailing list