bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: best way to test for empty dir?


From: Antonio Macchi
Subject: Re: best way to test for empty dir?
Date: Tue, 15 Dec 2009 16:05:55 +0100
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

[ -e "foo" -o -L "foo" -a ! -e "foo" ]


it has no sense doing twice the "-e" test


$ ln -s nonexistent foo

$ [ -e "foo" -o -L "foo" -a ! -e "foo" ] && echo ok || echo ko
ok

$ [ -e "foo" -o -L "foo" ] && echo ok || echo ko
ok


as you can see, the first "-e" check imply the second one
(aka, if the first "-e" is false, necessarily the second one will be true...)


maybe you have "too rougly" join the trick to check a broken link

-L "foo" -a ! -e "foo"

but in this particular case you don't have to check "only" broken links, but every file, broken links included...

so every file but broken links is "-e"
links and broken links is "-L"

join together -e and -L
every file, included links and broken links

ok?
bye




reply via email to

[Prev in Thread] Current Thread [Next in Thread]