From: DervishD <raul@pleyades.net>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Finding empty directories
Date: Thu, 23 Oct 2003 17:35:25 +0200 [thread overview]
Message-ID: <20031023153525.GB52@DervishD> (raw)
Hello all :)
I want to test if a directory is empty or not and I've thought
that I could test for the expansion of dirname/*(DN[1]). If this is an
empty string, then the directory is empty, otherwise it has at least
one file.
Anyway I was wondering if is there a better way of doing that
using just zsh code, with no external commands (I know I can do a
'find -type d -empty', for example, or 'ls | wc -l', etc...).
I would like to test if a filename correspond to a dangling
symlink, too. I can find dangling symlinks using **/*(-@), but if I
just have a file listing, how can I test if a file is a dangling
symlink or not? I've found that doing the following test:
[[ -h file && ( -r file || -d file ) ]]
will only return true for a symlink that really points to a file
or a directory, and false otherwise, but I'm not sure if this is a
proper way or if it will fail miserably on some obscure case :? In
fact, I'm not sure if '-r' and '-d' follow symlinks by default :?
Thanks in advance for your help ;)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
next reply other threads:[~2003-10-23 15:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-23 15:35 DervishD [this message]
2003-10-23 17:40 Bart Schaefer
2003-10-23 18:16 ` DervishD
2003-10-24 14:44 ` Bart Schaefer
2003-10-25 17:55 ` DervishD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031023153525.GB52@DervishD \
--to=raul@pleyades.net \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).