[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Wed, Apr 20, 2011 at 06:05:43PM +0100, Gordon Henderson wrote: > On Wed, 20 Apr 2011, Henry Bremridge wrote: > > >I seem to recall there was a series of discussions on using Find to > >discover (and delete) empty directories. From memory there was a one line > >command that would do it. > > > > Using tar to back up new files from a certain date from the wife's > > hard-drive. I now have to unpack the tar file and delete empty > > directories. > > Out of curiosity, why bother deleting them? > Was asked to... > >I tried searching this morning but could not find any. > > > >Before I started experimenting Google has the following commands > > > > find -depth -type d -empty -exec rmdir {} \; > > find -type d -empty -delete > > > > http://duramecho.com/ComputerPrograms/DeleteEmptyDirectories/index.html > > > >Any help much appreciated > > The above mentioned commands seem to work for me, so what's up? From what I recall there was a series of recommendations and I wanted to see if one was better > > Find is great, although in this instance you probably don't need > -depth, as you can't go deeper than an empty directory, so: > > find . -type d -empty -print > > Remember that find's predicates are assumed to be concatenated with > 'and' unless you use -o (for 'or') > > So that reads as: > > find from the current directly ('.'), > type d (directory) > and > empty > and > print > > You can use -ls rather then print if you like. > > Once happy with that, then you can add on the -exec rmdir {} \; > Many thanks -- Henry Photocopies or faxes of my signature are not binding. This email has been signed with an electronic signature in accordance with subsection 7(3) of the Electronic Communications Act 2000. Digital Key Signature: GPG RSA 0xFB447AA1 or 0x3184D537 Smime Fingerprint 98:24:AE:F7:D1:D6:E5:A0:F0:55:2F:40:42:5F:46:24:F9:52:f4:30 Wed Apr 20 18:48:26 BST 2011
Attachment:
signature.asc
Description: Digital signature
-- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/listfaq