Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case Statement 1

Status
Not open for further replies.

smicro

MIS
Dec 26, 2002
281
US
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
 
a loop?

for FILE in "$UNIXERR" "$NTERR" "$DBERR" "$LOTUSERR"
do
if [ -s "$FILE" ]
...
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top