I am using Putty, and I have a folder with lots of subfolders and files in each. I need a command to know the size of the whole folder with all what’s in it, and the number of total files for all that folder.
I know this command
du -h foldername
but it lists the size of each and every subfolder, then gives the size of the total folder, but the number is not exact (i.e. shows 7.8G instead of how many bytes exactly), and doesn’t show the number of total files.
Your friend is “find”, along with “wc” which counts lines.
find foldername -type f | wc -l
If you want file sizes, du -k instead of -h will show you size in k. You also have the option of piping to ls -l, and summarizing the byte counts using a quick awk or perl script