[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: best way to test for empty dir?
From: |
Greg Wooledge |
Subject: |
Re: best way to test for empty dir? |
Date: |
Fri, 11 Dec 2009 12:02:30 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Fri, Dec 11, 2009 at 04:16:13PM +0000, Marc Herbert wrote:
> In case anyone is interested my winner (so far) is:
>
> exists()
> {
> [ -e "$1" -o -L "$1" ]
> }
>
> if exists foo/*; then
> for f in foo/*; do
> ...
> done
> fi
What if there's a subdirectory or something and you'd like to skip it?
for f in foo/*; do
test -f "$f" || continue
...
done
Hence my explanations at the bottom of http://mywiki.wooledge.org/BashFAQ/004
- Re: best way to test for empty dir?, (continued)
- 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, 2009/12/10
- 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 <=
- 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
- Re: best way to test for empty dir?, Marc Herbert, 2009/12/14
- Re: best way to test for empty dir?, Matias A. Fonzo, 2009/12/14
- Re: best way to test for empty dir?, Andreas Schwab, 2009/12/15
- Re: best way to test for empty dir?, Matias A. Fonzo, 2009/12/15
- Re: best way to test for empty dir?, Andreas Schwab, 2009/12/15
- Re: best way to test for empty dir?, Matias A. Fonzo, 2009/12/15
- Message not available
- Re: best way to test for empty dir?, Antonio Macchi, 2009/12/15