So, here is a small shell script for you people which will help you list the disk usage or size of all sub directories in a current directory. To get the disk usage of all files and directories in a current directory you can simplly use the following command.
du -sh *
But if you want to get only the size of all the directories available in a particular directory, then you can propably use this bash shell script.
for i in `ls -p | grep ‘/’ | cut -d’/’ -f1`
echo “$i –> $size”
The above bash script caliculates the size of each subdirectory for one level and caliculates its size and gives you the output.
If you like this article, then please consider sharing it. Sharing really inspires us to do things much better!!