1834814 Members
2400 Online
110070 Solutions
New Discussion

Re: find

 
SOLVED
Go to solution
Tommy Wang
Occasional Advisor

find

I got problem in performing the following command line:
% find . -type f -mtime +30 -exec rm{} ;

Why does it work?

Thanks in advance.
11 REPLIES 11
Devbinder Singh Marway
Valued Contributor

Re: find

after the last } you need a space and backslash
i.e find ..... rm{} ;

Seek and you shall find
John Palmer
Honored Contributor

Re: find

Why does it work? or why doesn't it work?
What exactly is your problem?

The command
'find . -type f -mtime +30 -exec rm {} \;'

will remove files in the current directory (and any sub-directories) which have a modified time earlier than 31 days from now.
Devbinder Singh Marway
Valued Contributor

Re: find

oops i may have the wrong end of the stick , do you want to know how it works ? or why doesn't it work ? ( too early... )

thanks
Seek and you shall find
federico_3
Honored Contributor

Re: find


The command you should run is:

find . -type f -mtime +30 -exec rm{} ;

Federico
federico_3
Honored Contributor

Re: find

sorry i forgot......

find . -type f -mtime +30 -exec rm{} ;

federico_3
Honored Contributor

Re: find

it seems that the back slash command before ";" can't be written
Tommy Wang
Occasional Advisor

Re: find


# ll |wc
84 749 5875
# find . -type f -mtime +30 -exec {} ;
# ll |wc
84 749 5875

I run the above command, but it doesn't work.
John Palmer
Honored Contributor

Re: find

Kenny,

The 'rm' is missing from your last post, is that a typo?

Specifying a null command to '-exec' will not give an error and will do nothing.

What are the dates on your files?

I assume that the backslash has been eaten by the system. You need to type two(//) to get one on this forum.

Regards,
John
federico_3
Honored Contributor
Solution

Re: find

try :

find . -type f -mtime +30 | xargs rm


I hope this helps
Tommy Wang
Occasional Advisor

Re: find

Thank you all for looking at this problem.
wagley 2 10-18
Frequent Advisor

Re: find

Hi all,

The backslash will be fixed in the next release scheduled for late October. Thank you for bringing this matter to our attention and for being so patient.

Kind regards,

Shayne Wagley
ITRC Forums Administrator
Hewlett-Packard
Live the moment and the energy of that moment will spread beyond all boundaries.