Operating System - HP-UX
1834312 Members
2394 Online
110066 Solutions
New Discussion

Re: Help on deleting files

 
Mike_305
Super Advisor

Help on deleting files

Hello,

We have archives directory and trying get rid of lots of files but ll is talking too long to run and all the files in the directory are "0" size as far as I know.

We want to keep the files for year of 2009.

This is what I am trying to do but since "ll" is talking too long is not helping me out.

Does any guru's have better idea?

Appreciate your help and thanks in advance....MP

===============================
ll | grep “2007” | cut –c61-72 > /tmp/file1
for X in $(cat /tmp/file1)
do
rm ${X}
done

or other process is

cat /tmp/file1 | sed –e “s/^/rm ” > /tmp/file2 - and then run file2 as delete the files.
=======================================
If there is problem then don't think as problem, think as opportunity.
4 REPLIES 4
Doug O'Leary
Honored Contributor

Re: Help on deleting files


Hey;

find . -mtime +93 -print | xargs -i rm {}

HTH;

Doug O'Leary

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
James R. Ferguson
Acclaimed Contributor

Re: Help on deleting files

Hi:

This will speed things up a bit, since one 'rm' process will remove multiple files instead of just one at a time:

# touch -amt 01010000 /tmp/ref
# find /path -type f ! -newer /tmp/ref -exec rm {} +

Regards!

...JRF...
Tingli
Esteemed Contributor

Re: Help on deleting files

find /archive_directory -mtime +93 -exec rm {} \;
Mike_305
Super Advisor

Re: Help on deleting files

Thanks for your help.
If there is problem then don't think as problem, think as opportunity.