Nicholas Leippe wrote:

On Tuesday 08 March 2005 05:16 pm, Eric Jensen wrote:


Working with a new backup scheme and trying to think of a good way to
delete all sub folders of a directory, but not any files in the root of
the directory. For example, I have a directory structure like:
/2005/03/08. Folder '03' has a folder for every single day with the
daily backups. At the end of the month I am moving the last day's
backups to the root of the month's folder (03) and then want to clear
out all the daily folders. I could just copy them to a temporary
folder, do the traditional rm -rf and move the files back. But curious
to know if there is a handier way to do this, since I'm sure it will
come up again.



find /2005/03/ -maxdepth 1 -type d | xargs rm -rf



Close, tried that already but the problem is it finds /2005/03/ and performs rm -rf on it as well. I am trying to play with expressions so I can do something like !/2005/03/ but I am new to find and not doing to hot on syntax.

Hmm... Just changed /2005/03/* and that seemed to work better. Quick question, what is the difference of doing something like:

`find stuff | rm -rf ` and `find stuff | xargs rm -rf `?

Some day this find stuff will stick around in my brain long enough for me to stop asking questions like this here. man find just ends up confusing me even more. ;) Thanks again.

Eric Jensen
.===================================.
| This has been a P.L.U.G. mailing. |
|      Don't Fear the Penguin.      |
|  IRC: #utah at irc.freenode.net   |
`==================================='

Reply via email to