So the problem is that you have a script that needs to count how many files are in a directory in order to perform a function, but how do you do it"
ls -1|wc -lThat will give you the number, but it's also counting any folders, we just want files.
ls -R1 /path|grep -v /|grep -vx ""|grep -vx "\.*"|wc -lIf we wanted to include hidden files we would use:
ls -Ra1 /disk_array/backups/|grep -v /|grep -vx ""|grep -vx "\.*"|wc -lIf we want to exclude directory in that path from being counted:
ls -Ra1 /disk_array/backups/|grep -v /path to exclude|grep -v /|grep -vx ""|grep -vx "\.*"|wc -l