Operating System - HP-UX
1834015 Members
2328 Online
110063 Solutions
New Discussion

Re: how to delete files older than jan 01, 2007

 
SOLVED
Go to solution
MD Shafiullah
Occasional Advisor

how to delete files older than jan 01, 2007

Hi all, I am using the bellow procedures to list files that are older than jan 01, 2007.

touch -t 200701010000 /tmp/timeref
find /tmp -type f !-newer /tmp/timeref -exec ll {}\;

It is showing "find: missing conjunction"
Can anyone help?
4 REPLIES 4
Jeeshan
Honored Contributor
Solution

Re: how to delete files older than jan 01, 2007

put a space after f ! and a space after {}

find /tmp -type f ! -newer /tmp/timeref -exec ll {} \ ;
a warrior never quits
MD Shafiullah
Occasional Advisor

Re: how to delete files older than jan 01, 2007

Thanks Ahsan vi. I did that. I also found the bellow syntax very useful.

find ./fi* -mtime +30 -exec ls -l {} \;

This will delete files older that 30 days.
Cheers!!
Dennis Handly
Acclaimed Contributor

Re: how to delete files older than jan 01, 2007

>I also found the below syntax very useful.
find ./fi* -mtime +30 -exec ls -l {} \;

Both of these will go lots faster if you replace that "\;" by just "+".

>This will delete files older that 30 days.

Well, list them. Replace "ls -l" by "rm".
piyush mathiya
Trusted Contributor

Re: how to delete files older than jan 01, 2007

Yes,
We can remove the older files with find utility, there is . . .

find -name -mtime +30 -exec rm -f {} \;

where path is the full absolute path or "." if you want to find in your present directory & if you want to add a query of selected file name then you can give the file name too.

I will definitely works.

Regards,
Piyush Mathiya