Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: quick and dirty test for empty directory



On Wed, Nov 16, 2022 at 5:18 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Best advice googling for such a test is this:
>
>                  [ -d "$dir" ] && [ -n "$(ls -A  $dir)" ]   # If true,
> dir isn't empty.

Try this:

  [[ -n $dir(#qNF) ]] && print -r -- "$dir is a non-empty directory"

This requires extended_glob.

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author