I have a ksh script that redirects stderr to a file:
exec 2>> ${ERROR_FILE}
at the end of the script I want to remove the ERROR_FILE if it is empty
(so I don't have a bunch of zero byte files sitting around). Is it ok
for me to do the following:
if [ ! -s "${ERRORFILE}" ]
then
# empty file...so no errors!
/usr/bin/rm -f ${ERRORFILE}
else
# write date to error file (for debugging purposes)
/usr/bin/date >&2
echo >&2
fi
What I'm wondering is whether or not I have to close stderr before
checking that it is empty. None of the commands in the shell script are
ran in the background.
Is there a better way to do this?
Thanks,
Don
--
Donald S. Mitchell
AT&T
Voice: (732) 805-7604
Fax: (732) 805-7320