[plug] deleting files

Russell Steicke r.steicke at bom.gov.au
Mon Apr 26 21:51:39 WST 2004


On Mon, Apr 26, 2004 at 08:29:08PM +0800, Jon  Miller wrote:
> I have in one directory over 1000 files that needs to be deleted.  Of
> course when I issue rm -rf * I get  message stating the argument list
> was too long.  Is there a way to issue a single command to delete the
> entire content of the directory?

This comes up every so often.  I thought that 1000 files was within the
arg list length limit (32768?).  Oh well...

  find . -mindepth 1 | xargs rm -rf

Or, if you have odd file names in there (particularly with white space
in them)

  find . -mindepth 1 -print0 | xargs -0 rm -rf

"-mindepth 1" tells find to not list its args (ie "."), so you won't be
rming the directory itself.



-- 
Russell Steicke

-- Fortune says:
The big cities of America are becoming Third World countries.
		-- Nora Ephron



More information about the plug mailing list