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

Re: Unix command(s) to remove files recursively?



On Tue, Jun 05, 2012 at 12:15:24PM BST, Wolodja Wentland wrote:
> On Tue, Jun 05, 2012 at 12:01 +0100, rjc wrote:
> > > Suppose that I have, in a certain directory and all its subdirs and subdirs'
> > > subdirs' subdirs... etc., a certain number of files terminating with `~', e.g.:
> > > `myfile~', and that I want to remove all of them recursively.  Is there a Unix
> > > command to do that right away?
> > 
> > find top_dir_name -type f -name "*~" -exec rm '{}' \;
> 
> No need for -exec rm here ... You can just use -delete (please read the manpage!).

No need to shout.

I'm well aware of "-delete" existence, however it is not portable or
required by POSIX (e.g. some versions of Solaris don't have it) so
"-exec rm" is more "Unix" (specifically mentioned by the OP) than
"-delete" in this example.

Cheers,
-- 
rjc


Reply to: