I have directory contains many subdirectories and each subdirectory has a couple of files (interested only to files with .ar extension). Now, I need to loop through each subdirectory and check, for example, if the number of the files = 4 then do something to these files, go back to the second subdirectory check the files if = 3 then do another command on them. Note that, I have much-complicated conditions I have to apply on the if statement.
something similar to this
dir=$1 for sub_dir in $dir; do if the number of files in $sub_dir = 4; then do something or command line if the number of files in $sub_dir = 3; then do another command if the number of files in $sub_dir < 3; then escape them fi done
I need a template for a similar process.