Question for a friend:
In a Bash script, while iterating over a list of directories, what is the most elegant and efficient[1] method of testing "does this directory exist and have files in it"
[1]where efficiency is defined as the least amount of disk access followed by least amount of processing.
--
Personally I'd use something like ls -1 $dir 2> /dev/null | wc -l and test for return values above 1. Can you do this more efficiently by looking at the inode (or some other method)?
[1]where efficiency is defined as the least amount of disk access followed by least amount of processing.
--
Personally I'd use something like ls -1 $dir 2> /dev/null | wc -l and test for return values above 1. Can you do this more efficiently by looking at the inode (or some other method)?
