find *and* delete directories and/or files with only one command?

find *and* delete directories and/or files with only one command?

Post by Saibot Ree » Tue, 10 Oct 2006 18:59:34


howto find *and* delete directories and/or files with only one command?
 
 
 

find *and* delete directories and/or files with only one command?

Post by Philip Pae » Tue, 10 Oct 2006 19:14:36


With find(1). Please read the manual.

- Philip

--
Philip Paeps Please don't email any replies
XXXX@XXXXX.COM I follow the newsgroup.

When life hands you a lemon, make lemonade.

 
 
 

find *and* delete directories and/or files with only one command?

Post by conrad » Mon, 16 Oct 2006 10:25:29

In article <slrneik88c.2fqr.philip+ XXXX@XXXXX.COM >,



Well, let's face it, the man page for find is not that easy a read for a
relative newcomer. It took me quite some time to learn how to use some of
find's more powerful features, a lot of which I picked up through reading
the followups to questions about find in the newsgroups. :-)

To answer the OP's question in brief:

For files:

find some-path(s)-to-search optional-matching-criteria -delete

More elaborate arrangements are possible, of course, but this is the
barebones crux of the matter.

As Philip mentioned, read the man page for more info. *Lots* more info.
:-)

--
Conrad J. Sabatier < XXXX@XXXXX.COM > -- "In Unix veritas"
 
 
 

find *and* delete directories and/or files with only one command?

Post by conrad » Mon, 16 Oct 2006 10:30:07

In article <d6gYg.28077$Go3.23837@dukeread05>,


[snip]


Disregard the above qualification; for the longest time I was under the
impression that the -delete primary only worked with files, not directories,
but a quick check of the man page just now would seem to indicate otherwise:

-delete
Delete found files and/or directories. Always returns true.
This executes from the current working directory as find recurses
down the tree. It will not attempt to delete a filename with a
``/'' character in its pathname relative to ``.'' for security
reasons. Depth-first traversal processing is implied by this
option.
--
Conrad J. Sabatier < XXXX@XXXXX.COM > -- "In Unix veritas"