Is there a way to count how many files in a specific directory are over some file size? Say, 100 MB?
Asked
Active
Viewed 7,785 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?](/q/1125/23408), [How to count recursively the number of files in several directories?](/q/70993/23408), [Script to count files matching a pattern in subdirectories](/q/27389/23408), [How to use wc and piping to find how many files and directories are in a certain directory?](/q/101415/23408), [Reporting number of files in subdirectories](/q/500417/23408), [Number of folders in a directory (recursive)](/q/167228/23408), [No of files and directories in a particular directory in shell script](/q/200293/23408), 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
- 78,509
- 12
- 109
- 152
-
-
1@mirekphd `find ... -printf 1 | wc -c` is preferred over `find ... -print | wc -l` because the latter will miscount files whose names contain newlines – steeldriver May 18 '22 at 11:45