Scunningham99
Programmer
Morning all
I would like to create a script which will delete all files but the latest.
Here is what i have got, but it doesnt seem to be working. Please can someone help me.
kind regards
S
while [ 1 ]
echo $$ > /u00/DBA/scripts/rmArchLogs.txt # write PID to text file
#find the latest archive file
cd /u02/archive/ALIVE_SB/
FILE=`ls -tr *.arc | tail -1`;
do #loop through files to delete
#Delete Files if it does not = the latest file!!
FILE_RM=`ls *.arc`;
if ( $FILE_RM -ne $FILE ); then
echo deleting file ... $FILE_RM
fi;
sleep 300 # sleep for 5 min
done # end loop
Sy UK
I would like to create a script which will delete all files but the latest.
Here is what i have got, but it doesnt seem to be working. Please can someone help me.
kind regards
S
while [ 1 ]
echo $$ > /u00/DBA/scripts/rmArchLogs.txt # write PID to text file
#find the latest archive file
cd /u02/archive/ALIVE_SB/
FILE=`ls -tr *.arc | tail -1`;
do #loop through files to delete
#Delete Files if it does not = the latest file!!
FILE_RM=`ls *.arc`;
if ( $FILE_RM -ne $FILE ); then
echo deleting file ... $FILE_RM
fi;
sleep 300 # sleep for 5 min
done # end loop
Sy UK