[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible enhancement: file count
From: |
Stephane Chazelas |
Subject: |
Re: Possible enhancement: file count |
Date: |
Tue, 1 Mar 2016 17:57:23 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2016-02-29 08:48:16 -0700, Eric Blake:
> On 02/29/2016 08:23 AM, Fernando Pereira wrote:
>
> > Anyway, I was looking for the most efficient way to do that and I couldn't
> > find satisfying answer. Of course we can use find | wc, but I am really
> > looking for a simple and efficient solution just like du exists for the
> > file size.
>
> But 'find | wc' IS efficient, and already exists on every machine,
> whereas a new method would only be available on machines updated to the
> latest-and-greatest. Pipelines are cheap; I don't see any benefit to
> bloating tools with a new option when existing options work well.
[...]
Efficient but wrong unless you can guarantee file names won't
contain newline characters.
Portably:
find .//. | grep -c //
GNUly:
find . -printf . | wc -c
Note that it counts ".", but none of the "." or ".." entries in
any of the directories.
But I think the OP was looking for a report a la du to get a
summary of the number of files per directory (which you can then
pipe to xdu/xdiskusage for instance to get a graphical
representation).
--
Stephane