Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

How to delete files when argument list too long

Mike Peters, 01-23-2014
Ever try to delete a lot of files in a folder, only to have the operation fail with "Argument list too long"?

Here's how to get it done:

FreeBSD

find
. -name "*.pdf" -print0 | xargs -0 rm

Note that this is a recursive search and will find (and delete) files in subdirectories as well.

Linux

find
. -name "*.pdf" -maxdepth 1 -print0 | xargs -0 rm

Mike Peters, 01-23-2014
Here's another useful one -

How to delete all files with size 0 (delete empty files):


find
. -size 0 -print0 | xargs -0 rm
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions