coreutils
[Top][All Lists]
Advanced

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

RE: Getting inode counts from "du --inodes" clarification


From: SCOTT FIELDS
Subject: RE: Getting inode counts from "du --inodes" clarification
Date: Mon, 13 Feb 2023 20:31:36 +0000

No, because I'm looking to get all directories under the given path 
represented, as my example shows.

I do want the entire directory tree traversed, but I'm wanting only the number 
of top level objects in each directory reported as far as counts are for each 
directory.

I appreciate your response.

-----Original Message-----
From: Bernhard Voelker <mail@bernhard-voelker.de> 
Sent: Monday, February 13, 2023 1:59 PM
To: SCOTT FIELDS <Scott.Fields@kyndryl.com>
Cc: coreutils@gnu.org
Subject: [EXTERNAL] Re: Getting inode counts from "du --inodes" clarification

On 2/10/23 23:47, SCOTT FIELDS wrote:
 > I'm looking to get the number of files in each directory under a given path  
 > > But only the top level of each directory (don't include files/directories 
 > from  > subdirectories in each processed directory)  >  > Example from your 
 > statement:
 >
 > # du --inodes -d 0 --all /usr
 > 119613  /usr
 >
 > In this case, the number of entries directly within /usr is 15 (files, 
 > directories, etc), but this is reporting all the files that exists within 
 > /usr and all other subdirectories.
 >
 > A script that does what I mean is fairly simple but hardly a simple one 
 > liner.
 >
 > --
 >
 > for directory in $(find <directory> -type d); do echo "$(ls -a $directory \
 >   | sed '/^\.$/d;/^\.\.$/d'| wc -l) $directory"; done


I see.  du(1) traverses the whole directory hierarchy, so that's not wanted 
anyway.
And --max-depth only changes which levels get printed and which not).

One could of course try to work with an --exclude pattern, but that's awkward.

Your direction with find(1) looks better - but with the -mindepth and -maxdepth 
option:

   find /usr -mindepth 1 -maxdepth 1 -printf x | wc -c
   12

Does this come closer to what you want to achieve?

Have a nice day,
Berny

reply via email to

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