PDA

View Full Version : /bin/rm: Argument list too long - deleting tons of files



b0nd
04-17-2013, 03:55 PM
You might confront issue deleting tons of files from a directory using command # rm *
Error Message: bash: /bin/rm: Argument list too long

Following commands are the saviours, though few more surely be there:

find . -type f -print -delete
find . -name "*" -print | xargs rm

Cheers!

rebeccazoly
06-04-2013, 04:49 AM
I have download Long Path Tool and it is the best solution of your problem.

b0nd
06-04-2013, 10:49 AM
I have download Long Path Tool and it is the best solution of your problem.

Dude, the solution I posted is for *nix flavors. Your Long Path Tool is for windows (

No special system requirements. LONG PATH Tool works on any Windows version (NT/2000/XP/Vista/Windows 7/Windows 8).)

jimmy
07-03-2013, 04:52 PM
thanks for your information, but I have not encountered problem as it..
what causes so it appears like it?

c0dist
08-19-2014, 11:39 AM
Something I stumbled across on Quora.

$ mkdir empty_dir$
$ rsync -a --delete empty_dir/ yourdirectory/

Source - http://qr.ae/uErOf

c0dist
08-20-2014, 12:53 PM
Also, since I can't edit my last reply, here's the interesting comparison of various methods,

http://g33kinfo.com/info/archives/5630
http://www.slashroot.in/which-is-the-fastest-method-to-delete-files-in-linux

rsync does seem to be very fast.

Hope this helps.

b0nd
04-30-2015, 05:14 AM
rsync indeed is very fast and the best so far I've found for my usages. But it almost freezes your computer and shouldn't be used on any production server.

Cheers!

c0dist
04-30-2015, 01:01 PM
Oh, another thing. There's one more faster way, Perl. Here is the Perl syntax for doing that,


$ perl -e 'for(<*>){((stat)[9]<(unlink))}'

OR


$ perl -e 'unlink <*>'

Source: http://www.quora.com/Linux-why-stat+unlink-can-be-faster-than-a-single-unlink/answer/Kent-Fredric?__snids__=658761123&__nsrc__=2#