I am new to linux. I have a directory in linux with approx 250,000 files I need to find count of number of files matching a pattern.
I tried using following command :
If you are attempting to do this in the command line on a Mac you will soon find out that find
does not support the -printf
option.
To accomplish the same result as the solution proposed by fedorqui-supports-monica try this:
find . -name "pattern_*" -exec stat -f "." {} \; | wc -l
This will find all files matching the pattern you entered, print a .
for each of them in a newline, then finally count the number of lines and output that number.
To limit your search depth to the current directory, add -maxdepth 1
to the command like so:
find . -maxdepth 1 -name "196288.*" -exec stat -f "." {} \; | wc -l