telemorgan
MIS
I have a directory that will house oracle dump files and their log files. I am looking for a way that I can keep the latest log\dump files and remove the rest. I have script'ed the section to identify the latest dump file in the directory but i'm having trouble with removing all the files but the one I want to keep.
::EXAMPLE::
the files in the directory are listed below (note the dates will constantly change)
deltekcp_2005042820.dmp.Z
deltekcp_2005042920.dmp.Z
deltekcp_2005043020.dmp.Z
deltekcp_2005050120.dmp.Z
deltekcp_oraexp_2005042820.log
deltekcp_oraexp_2005042920.log
deltekcp_oraexp_2005043020.log
deltekcp_oraexp_2005050120.log
I identified that I want to keep the file *120.log and its corresponding dump file. How can I remove the rest of the files in the directory if their names are alway going to be different while keeping the one that I want.
Is there an easier way than this?:
mv deltekcp_oraexp_2005050120.log deltekcp_oraexp_2005050120.tmp
mv deltekcp_2005050120.dmp.Z deltekcp_2005050120.dmp.Z.tmp
rm deltekcp*
mv deltekcp_2005050120.dmp.Z.tmp deltekcp_2005050120.dmp.Z
mv deltekcp_oraexp_2005050120.tmp deltekcp_oraexp_2005050120.log
::EXAMPLE::
the files in the directory are listed below (note the dates will constantly change)
deltekcp_2005042820.dmp.Z
deltekcp_2005042920.dmp.Z
deltekcp_2005043020.dmp.Z
deltekcp_2005050120.dmp.Z
deltekcp_oraexp_2005042820.log
deltekcp_oraexp_2005042920.log
deltekcp_oraexp_2005043020.log
deltekcp_oraexp_2005050120.log
I identified that I want to keep the file *120.log and its corresponding dump file. How can I remove the rest of the files in the directory if their names are alway going to be different while keeping the one that I want.
Is there an easier way than this?:
mv deltekcp_oraexp_2005050120.log deltekcp_oraexp_2005050120.tmp
mv deltekcp_2005050120.dmp.Z deltekcp_2005050120.dmp.Z.tmp
rm deltekcp*
mv deltekcp_2005050120.dmp.Z.tmp deltekcp_2005050120.dmp.Z
mv deltekcp_oraexp_2005050120.tmp deltekcp_oraexp_2005050120.log