Is there a way to count how many files in a specific directory are over some file size? Say, 100 MB?
Asked
Active
Viewed 8,531 times
0
-
1Combined with https://unix.stackexchange.com/questions/4105/how-do-i-count-all-the-files-recursively-through-directories – muru Jul 13 '19 at 03:00
-
Related: How can I count the files in a directory using the command line?, How to count recursively the number of files in several directories?, Script to count files matching a pattern in subdirectories, How to use wc and piping to find how many files and directories are in a certain directory?, Reporting number of files in subdirectories, Number of folders in a directory (recursive), No of files and directories in a particular directory in shell script, etc. – Scott - Слава Україні Jul 13 '19 at 09:01
1 Answers
3
Perhaps
find path/to/directory/ -type f -size +100M -printf 1 | wc -c
Or, if you want to limit the search to the top level directory only (without descending into subdirectories)
find path/to/directory/ -maxdepth 1 -type f -size +100M -printf 1 | wc -c

steeldriver
- 81,074
-
-
1@mirekphd
find ... -printf 1 | wc -c
is preferred overfind ... -print | wc -l
because the latter will miscount files whose names contain newlines – steeldriver May 18 '22 at 11:45