is there a way to read the cumulative size of all files in a folder?
8,071
Solution 1
You can use the du command:
du -sh foldername
Solution 2
du -s folder
-s
stands for summarize.
Solution 3
You can also use
du -csh foldername/*
which gives file and folder sizes under "foldername" separately and the total size in last row.
Related videos on Youtube
Author by
ewok
Updated on September 18, 2022Comments
-
ewok over 1 year
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? -
user9320 about 4 yearsThe
-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 usedu -csh folder/*.js
to measure only the JS files, omitting CSS and HTML.