I had to check in a project, if many import processes already finished. As these processes merely imported files from the file system into a database, I decided to check if there were any files in the file system – instead of clicking through 25 processes in the admin GUI to see if they were finished. Therefore i had to check how many files were in a specific folder structure.
There is an easy way on Linux/Unix to count the number of files in a folder structure.
First you have to issue the find command to retrieve only the filenames in the appropriate structure. Afterwards you just have to return the wordcount of the result of the find command.
The combined command is:
$ find /opt/data2import/ -type f | wc -l
It also works great with wildcards:
$ find /opt/data/*/data2import/ -type f | wc -l