[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: deleting files



E.L. Meijer Eric wrote:
>On Tue, Nov 23, 1999 at 05:00:01PM +1300, zdrysdal@diagnostic.co.nz wrote:
>> does anyone happen to know of a quicker way of deleting 40000 files out of
>> a directory other than the command "find . -exec rm {} \;"
>> 
>> will rm -r <directory> be as quick?
>
>It will actually be much quicker (you may need to add a -f option as
>others pointed out).  The find command will start the rm command for
>each file separately, so you will run rm 40000 times instead of one
>time.  If you need `find' to select files on specific criteria, like
>name, user, or date, you should use it together with xargs:
>
>find . -name \*.tmp -print | xargs rm -f {} \;
>
>This will start rm the minimum amount of times with maximum length
>command lines.

xargs doesn't use 'find -exec'-style syntax, so:

  find . -name \*.tmp -print | xargs rm -f

... is enough. The other one will work, but will try to remove two
extraneous files called '{}' and ';'. :)

-- 
Colin Watson                                           [cjw44@cam.ac.uk]
Trinity College, Cambridge, and Computer Science         [riva.ucam.org]


Reply to: