rm argument list too long find and xargs

Chris F.A. Johnson chris-E7bvbYbpR6jSUeElwK9/Pw at public.gmane.org
Mon Apr 12 16:37:30 UTC 2010


On Mon, 12 Apr 2010, teddymills wrote:

> 
> I was trying to rm more than 1024 files at one time (old logs)
> and rm returned a strange error. "Argument list too long"
> 
> so find and xargs to the rescue..
> find . -name 'myDEBUG*.log' | xargs rm

    There is no need for xargs with recent versions of find:

find . -name 'myDEBUG*.log' -exec rm {} +


> http://en.wikipedia.org/wiki/Xargs
> uname -a shows a kernel less than 2.6.23

-- 
   Chris F.A. Johnson, <http://cfajohnson.com>
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list