Can someone give me some suggestions if I can clean this up?
Basically I need to check if a file exists and not empty if so then I need to take the first 3 lines out of one file and put it into another. I can't use else statements( I don't think) because I need to check all of them and do different things for each one. I was thinking a case statement but wasn't sure how to get the command as part of the statement to check if the file exists.
if [ -s "$UNIXERR" ]
then
sed 3q errormail > $TMP1
cat $UNIXERR >> $TMP1
mv $TMP1 $UNIXERR
fi
if [ -s "$NTERR" ]
then
sed 3q errormail > $TMP1
cat $NTERR >> $TMP1
mv $TMP1 $NTERR
fi
if [ -s "$DBERR" ]
then
sed 3q errormail > $TMP1
cat $DBERR >> $TMP1
mv $TMP1 $DBERR
fi
if [ -s "$LOTUSERR" ]
then
sed 3q errormail > $TMP1
cat $LOTUSERR >> $TMP1
mv $TMP1 $LOTUSERR
fi
Basically I need to check if a file exists and not empty if so then I need to take the first 3 lines out of one file and put it into another. I can't use else statements( I don't think) because I need to check all of them and do different things for each one. I was thinking a case statement but wasn't sure how to get the command as part of the statement to check if the file exists.
if [ -s "$UNIXERR" ]
then
sed 3q errormail > $TMP1
cat $UNIXERR >> $TMP1
mv $TMP1 $UNIXERR
fi
if [ -s "$NTERR" ]
then
sed 3q errormail > $TMP1
cat $NTERR >> $TMP1
mv $TMP1 $NTERR
fi
if [ -s "$DBERR" ]
then
sed 3q errormail > $TMP1
cat $DBERR >> $TMP1
mv $TMP1 $DBERR
fi
if [ -s "$LOTUSERR" ]
then
sed 3q errormail > $TMP1
cat $LOTUSERR >> $TMP1
mv $TMP1 $LOTUSERR
fi