directory – How to Calculate the Size of a Directory directory How to know the size of a directory? Including subdirectories and files. Best Answer du -s directory_name Or to get human readable output: du -sh directory_name The -s option means that it won't list the size for each subdirectory, only the total size. Related SolutionsLinux – How to remove all the files in a directory If your top-level directory is called images, then run rm -r images/*. This uses the shell glob operator * to run rm -r on every file or directory within images. Directory Size – Find Total Size of Certain Files Within Directory Branch find ./photos/john_doe -type f -name '*.jpg' -exec du -ch {} + | grep total$ If more than one invocation of du is required because the file list is very long, multiple totals will be reported and need to be summed. Related QuestionDirectory – How to Recursively Find Disk UsageHow to count subdirectories in a directory in UNIX
Best Answer
Or to get human readable output:
The
-s
option means that it won't list the size for each subdirectory, only the total size.