9

I want to read the size of a folder from the command line. ls -lh shows all folders as being 4k, which presumably is the size of the footprint of the folder itself, rather than the contained files. I would like to read the size of all contained files within the folder. is this possible?

3 Answers 3

12

You can use the du command:

du -sh foldername
4
du -s folder

-s stands for summarize.

4

You can also use

du -csh foldername/*

which gives file and folder sizes under "foldername" separately and the total size in last row.

1
  • 1
    The -c is helpful if you are selecting a subset of files in a folder. For example, if you're trying to see how big your web assets are, you could use du -csh folder/*.js to measure only the JS files, omitting CSS and HTML.
    – user9320
    Commented Apr 9, 2020 at 16:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .