Finding Hidden Directories in Linux

There are different ways in which you can file hidden directories in Linux. Sometimes it’s necessary to find those directories to see the amount of disk space that is being occupied by them. To find all Hidden directories, the general command is always a du * or du -a but there are other ways also which you can use the du command to sort and find the hidden directories and display them along with other directories.

#Finding all Hidden directories
du * or du -a

#Finding all Hidden directories with summarized size
du -hs .[^.]*

#Summarizing the Hidden directories 
du -hs $(ls -A)

#Finding and sorting hidden directories by their size
find -maxdepth 1 -exec du -sh "{}" \; | sort -h

#Some other ways to find hidden directories
du -sh *

du -sh * .*

There are also other ways for finding the hidden directories by using a combination of ls command and du together which makes sures that that filenames with spaces are correctly handled when du command is run

ls -A | xargs -I {} du -sh {}
ls -A | while read file; do du -sh "$file"& done | sort -h;

You may also like...