How to count number of files in a directory that are over a certain file size
6,302
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
Related videos on Youtube
Author by
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
Is there a way to count how many files in a specific directory are over some file size? Say, 100 MB?
-
muru almost 5 yearsCombined with unix.stackexchange.com/questions/4105/…
-
Scott - Слава Україні almost 5 yearsRelated: 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.
-
-
Admin about 2 years
$ find /tmp/ -maxdepth 1 -type f -print | wc -l
-
Admin about 2 years@mirekphd
find ... -printf 1 | wc -c
is preferred overfind ... -print | wc -l
because the latter will miscount files whose names contain newlines