Tricky Deleting
Charles Curley
charlescurley at charlescurley.com
Wed Mar 9 06:27:59 MST 2005
On Tue, Mar 08, 2005 at 05:21:16PM -0700, 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
Try
find /2005/03/* -maxdepth 1 -type d | xargs rm -r
^
instead. What you have will take out the directory 03, not what you
want.
Also, I wouldn't use the -f argument to rm. If something needs the -f,
I want to know what it is and where it came from, and fix it at the
source.
--
Charles Curley /"\ ASCII Ribbon Campaign
Looking for fine software \ / Respect for open standards
and/or writing? X No HTML/RTF in email
http://www.charlescurley.com / \ No M$ Word docs in email
Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://plug.org/pipermail/plug/attachments/20050309/58577156/attachment.bin
More information about the PLUG
mailing list