-1

I am using Red Hat Enterprise Linux Server release 5.6 (Tikanga). I wrote one shell script to delete files from specific folders.

find /app/psoft/pscfg/appserv/prcs/ABC/LOGS -type f -mtime +45  -exec ls {} \; >> "/app/Custom_Del_logs/prcslogs_`date  +%Y%m%d_%H%M`.log"

find /app/psoft/pscfg/appserv/prcs/ABC/LOGS -type f -mtime +45  -exec rm {} \;

the above script first list out all the files in mentioned log file which exceeds 45 days and then it will removed the files. But the requirement is the list out files should be with date. so that we can recognize easily.

0

Do the following:

$ dir=/app/psoft/pscfg/appserv/prcs/ABC/LOGS

$ outdir=/app/Custom_Del_logs

$ find $dir -type f -mtime +45 -ls >> ${outdir}/prcslogs_$(date +%Y%m%d_%H%M).log
  • thanks but i need the files only with date not with permission and all. – Mannaji Jun 14 '16 at 10:50
  • @Mannaji then please edit your question and show us your desired output. – terdon Jun 14 '16 at 13:50
-1

You may substitute the command ‍‍ls with stat -c "%n %y" , then you will get only last modify date info

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.