bash count files in directory recursively matchingattern 1

bash count files in directory recursively matchingattern

find . -type f -name '*.log' -printf x | wc -c

Here is what the above code is Doing:
1. find . -type f -name ‘*.log’ -printf x
– find all files in the current directory (.)
– that are of type file (-type f)
– that have a name ending in .log (-name ‘*.log’)
– and print an x for each file found (-printf x)
2. wc -c
– count the number of characters in the output of the previous command

Similar Posts