find
will include all files and directories under the paths given as parameters, filtering them based on rules given as additional parameteres. You can use
find "$dir" -type f -name 'glob*' -size 0 -print
Some find
implementations does not require a directory as the first parameter (some do, like the Solaris one) and will default to the current working directory (.
). On most implementations, the -print
parameter can be omitted, if it is not specified, find
defaults to printing matching files.
"$dir"
gets substituted by the shell with the value of the dir
variable (as from question)
-type f
limits it to files (no directories or symlinks)
-name 'glob*'
limits it to file that have name matching glob*
(filenames starting with glob
). To include all files, omit this
-size 0
only includes files with a size of 0 (the same in all units, for non-zero values, c
needs to be included to check the file size in bytes)
-print
is the action to perform with matching files. -print
will print the filenames. It can be omitted on standard compliant find
implementations. If it is not present -print
is implied.