Re: Folder size and number of files

Liste des GroupesRevenir à ol misc 
Sujet : Re: Folder size and number of files
De : rich (at) *nospam* example.invalid (Rich)
Groupes : comp.os.linux.misc
Date : 25. Sep 2024, 15:47:40
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vd149s$3mkj5$2@dont-email.me>
References : 1
User-Agent : tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
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.


Date Sujet#  Auteur
25 Sep 24 * Folder size and number of files6db
25 Sep 24 +- Re: Folder size and number of files1G
25 Sep 24 +- Re: Folder size and number of files1Rich
25 Sep 24 `* Re: Folder size and number of files3Lawrence D'Oliveiro
26 Sep 24  +- Re: Folder size and number of files1Mike Scott
26 Sep 24  `- Re: Folder size and number of files1G

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal