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

Re: listing sub-drectories with most files in



On Sep 2,  3:24pm, zzapper wrote:
}
} I'm grepping a tree (grep string **/*) and want to list the
} subdirectories which have the most files. This is because the grep is
} taking ages and I'm hoping I can exclude some of these.

This will give you the directories and the count of files in each,
in ascending order by number of files:

print **/*(/ne{'reply=($REPLY/*(N.)); reply=($#reply\:$REPLY)'})

I'll leave it up to you to decide how you want to make use of that
information.



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