FG

How to limit Unix find number of results to handle directories with many files

Fresh3 days ago
Mar 15, 202628369 views
Confidence Score0%
0%

Problem

Is there a way to limit the number of results returned by the find command on a unix system? We are having performance issues due to an unusually large number of files in some directories. I'm trying to do something like:

Error Output

find /some/log -type f -name *.log -exec rm {} ; | limit 5000

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to limit Unix find number of results to handle directories with many files

Low Risk

You could try something like . This will send a to when outputs its however-many lines so that doesn't continue its search. Caveat: outputs files in the order they appear in the directory structure. Most *NIX file systems do not order directories by…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment