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: Fri, 10 Feb 2023 22:47:29 +0000

Forgot to include coreutils mailing list.

-----Original Message-----
From: SCOTT FIELDS 
Sent: Friday, February 10, 2023 4:47 PM
To: Bernhard Voelker <mail@bernhard-voelker.de>
Subject: RE: [EXTERNAL] Re: Getting inode counts from "du --inodes" 
clarification

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

--


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

On 2/8/23 20:56, SCOTT FIELDS via GNU coreutils General Discussion wrote:
> I'm wanting to get a per directory inode report.
> 
> The problem I have with "du -inodes" is that the inode report for a directory 
> includes all inodes for subdirectories.
> 
> But...if I use "-S" the subdirectory entry itself isn't reported in the given 
> directory.
> 
> So...say I have a directory with 1000 subdirectories, but each subdirectory 
> only contains may 5 files, I'll get a response like this:
> 
> "du -inodes <directory>" report all the inodes in <directory, but also all 
> the inodes in the subdirectories (including the subdirectory itself).
> 
> While...if I run "du -inodes -S <directory>", <directory> will only report 
> the non-directory file references and non of the direct subdirectories (minus 
> the contents of those subdirectories).
> 
> Is there a command use I'm missing that will show be all directories with 
> their total first level entries count, only?

As there's no reproducer / example, I'm quite bit confused what is the point.

Maybe you want to try a combination with -d?

   -d, --max-depth=N     print the total for a directory (or file, with --all)
                           only if it is N or fewer levels below the command
                           line argument;  --max-depth=0 is the same as
                           --summarize

Have a nice day,
Berny

reply via email to

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