[Date Prev ][Date Next ][Thread Prev ][Thread Next ][Date Index ][Thread Index ]
Re: best way to test for empty dir?
From :
pk
Subject :
Re: best way to test for empty dir?
Date :
Thu, 10 Dec 2009 21:50:29 +0000
pk wrote:
>> is_file()
>> {
>> for f
>> do
>> [ -f "$f" ] && return
>> done
>> return 1
>> }
>>
>> is_file /path/to/dir/* || echo empty
>
> This fails if the directory contains a file called "*".
My bad, it works correctly. The only issue I see is maybe that "-e" would be
more appropriate than "-f" since the first (and perhaps only) element could
be a directory.
best way to test for empty dir? , Marc Herbert , 2009/12/10
Re: best way to test for empty dir? , Greg Wooledge , 2009/12/10
Re: best way to test for empty dir? , Matias A. Fonzo , 2009/12/10
Re: best way to test for empty dir? , Chris F.A. Johnson , 2009/12/10
Message not available
Re: best way to test for empty dir? , pk , 2009/12/10
Re: best way to test for empty dir? ,
pk <=
Re: best way to test for empty dir? , Marc Herbert , 2009/12/11
Message not available Re: best way to test for empty dir? , pk , 2009/12/11
Re: best way to test for empty dir? , Sven Mascheck , 2009/12/11
Re: best way to test for empty dir? , Chris F.A. Johnson , 2009/12/11
Re: best way to test for empty dir? , Sven Mascheck , 2009/12/11
Re: best way to test for empty dir? , Marc Herbert , 2009/12/11
Re: best way to test for empty dir? , Greg Wooledge , 2009/12/11
Re: best way to test for empty dir? , Matias A. Fonzo , 2009/12/11
Re: best way to test for empty dir? , Andreas Schwab , 2009/12/12
Re: best way to test for empty dir? , Matias A. Fonzo , 2009/12/12