Quick ?s
Cheat Sheets
Man Pages
The Lynx
Software

How do I delete files when there are too many for bash?

Category: Shell Tricks

Sometimes there are too many fils in a directory to be deleted by use of '*' because it expands larger than bash's ability to handle it.

There are several ways around this. You can use find with -exec to call "rm" but this forks an individual 'rm' process on each file.

One trick is to use xargs to clump 100 or so files per "rm" call and to run 5 "rm"s in parallel:

ls | xargs -P 5 -n 100 rm

Yals.net is © 1999-2009 Crescendo Communications
Sharing tech info on the web for more than a decade!
This page was generated Sat May 2 21:36:42 2009