I want to check how much of the total file storage for a specific user has been used on a specific directory. I am using ls -lR ./* | grep userid
to list files belonging to a specific user. But then how I can get the total file sizes of them?
Use awk
ls -lR ./* | grep userid | awk '{sum = sum + $5} END {print sum}'
You can do something like this, which will show you the size if each directory in the users home directory, and will print a total size of their home directory at the end (sum of all sub-directories).
du -sch /home/USER/*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With