Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check total file size of a specific directory for a specific user

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?

like image 796
Ken Avatar asked Jul 11 '11 00:07

Ken


2 Answers

Use awk

ls -lR ./* | grep userid | awk '{sum = sum + $5} END {print sum}'
like image 24
Ray Baxter Avatar answered Oct 29 '22 16:10

Ray Baxter


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/*
like image 123
Moe Matar Avatar answered Oct 29 '22 15:10

Moe Matar