Mailinglist Archive: opensuse (888 mails)

< Previous Next >
Re: [opensuse] bash test for empty dir
On Friday 21 January 2011 04:11:41 David Haller wrote:
num_subdirs() {
for dir; do
nlinks=$(stat -c '%h' "$dir");
subdirs=$(( $nlinks - 2 ));
### printf "'%s' has %d subdirectories.\n" "$dir" "$subdirs";

On the subject of portability, there are systems where it is possible to
create a hardlink to a directory (e.g. Mac OS X), so your answer may not be
correct on all systems.

Anders
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >