Is there a way to count how many files in a specific directory are over some file size? Say, 100 MB?
-
1Combined with unix.stackexchange.com/questions/4105/…– muruCommented Jul 13, 2019 at 3: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 - Слава УкраїніCommented Jul 13, 2019 at 9:01
Add a comment
|
1 Answer
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
-
-
1@mirekphd
find ... -printf 1 | wc -c
is preferred overfind ... -print | wc -l
because the latter will miscount files whose names contain newlines Commented May 18, 2022 at 11:45