Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #58448

Re: Folder size and number of files

From Rich <rich@example.invalid>
Newsgroups comp.os.linux.misc
Subject Re: Folder size and number of files
Date 2024-09-25 13:47 +0000
Organization A noiseless patient Spider
Message-ID <vd149s$3mkj5$2@dont-email.me> (permalink)
References <vd0gpr$3k64u$1@dont-email.me>

Show all headers | View raw


db <dieterhansbritz@gmail.com> wrote:
> I like typing in commands at the console. Is there
> a command that gives me the size of a given folder,
> and the number of files in it? I can do that with
> the GUI, right klick on the folder and Proprties,
> but would prefer to do it from a typed in command.
> 
> Is there one?

A single rollup command that does all this, no.

You construct what you need by combining the primitives together to get 
what you are looking for.

For size (if by 'size' you really mean the sum of the disk space 
consumed by the files inside the folder) then du with the --max-depth= 
(short form -d) option to prevent it from descending into sub-folders 
will give you the "disk used by all files inside".

du --max-depth=1 folder/

For count, there are several options.  If all the filenames inside are 
sane (as in do not themselves contain newlines) then this will give you 
the count:

ls folder/ | wc -l

If your filenames contain newlines, well, you've got a lot more work 
ahead....

If you really want a 'rollup' (because you use this often) you can 
create either a shell function or a shell script file somewhere on your 
path with a new name, i.e. size-count which does both of the above and 
then you can run:

size-count folder/

to get both the disk usage and files count.

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Folder size and number of files db <dieterhansbritz@gmail.com> - 2024-09-25 08:14 +0000
  Re: Folder size and number of files G <g@nowhere.invalid> - 2024-09-25 09:26 +0000
  Re: Folder size and number of files Rich <rich@example.invalid> - 2024-09-25 13:47 +0000
  Re: Folder size and number of files Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-09-25 21:33 +0000
    Re: Folder size and number of files Mike Scott <usenet.16@scottsonline.org.uk.invalid> - 2024-09-26 09:14 +0100
    Re: Folder size and number of files G <g@nowhere.invalid> - 2024-09-26 08:56 +0000

csiph-web