Every now and then I try to do things on a large amount of files – this often ends in a command error about “Too many files” or something similar. One solution to this is to send batches of information to the command instead of sending all at once.
Here is an example on how to delete files in batches of 1000 files:
ls | xargs -n 1000 rm -v
The trick here is the -n 1000 that will send the result from the ls command in batches of a 1000 results per time until the ls list is empty to rm. Neat ah? 🙂
Tested on RHEL 3
0 Comments.