Rank directories by the number of files they contain
Build a paste-ready command, then review its compatibility and effects before running it.
find <path> -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head -<count>Complete required fields to copy the generated command.
read-onlyno known side effects Compatibility
LinuxVerified for Linux using bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementsfindfind must be installed and available on PATH.
Version supportfind Current supported releasesVerified for linux using bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signals184221 /var/lib/app/cacheRepresentative successful output; values vary with the selected target and system state.
Known errorsfind: command not foundfind is missing or is not available on PATH.
Verifyfind {{path}} -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head -{{count}}The output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01findCommandRuns the find stage of this one-liner.
02<path>ParameterA value supplied in the Fill parameters section.
03-xdevOptionConfigures find with the -xdev option.
04-typeOptionConfigures find with the -type option.
05fArgumentPasses f to find.
06-printfOptionConfigures find with the -printf option.
07'%h\n'ArgumentPasses '%h\n' to find.
08|PipelinePasses the output on the left to the command on the right.
09sortCommandRuns the sort stage of this one-liner.
10|PipelinePasses the output on the left to the command on the right.
11uniqCommandRuns the uniq stage of this one-liner.
12-cOptionConfigures uniq with the -c option.
13|PipelinePasses the output on the left to the command on the right.
14sortCommandRuns the sort stage of this one-liner.
15-nrOptionConfigures sort with the -nr option.
16|PipelinePasses the output on the left to the command on the right.
17headCommandRuns the head stage of this one-liner.
18-<count>OptionConfigures head with the -<count> option.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
find /var -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head -5
Example output
184221 /var/lib/app/cache
42891 /var/spool/postfix/deferred
12842 /var/log/journal/8c1d…
Illustrative output — exact values vary by system and data.
Official sources