Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to tally up the total file space used by a user

Status
Not open for further replies.

chrilado

Technical User
Jun 2, 2003
2
AU
Could someone please help. AIX system being used

I have a directory which has user files in it - this directory is constantly filling up and i need to create a script which will be able to tally up the total file space used by each user.

1) Not sure how the script should work perhaps the first step would be for it to identify each user that has 1 or more files within the directory then produce a list of each user with the total number of files that user owns. (to identify the top 10 culprits of excess usage).

2) The next step would be to tally up the total space used by each user within that directory.

The output of 1 and 2 above could be combined in one output for ease of identification.

Alternatively perhaps some kind of interactive script were it would prompt for the directory to search in and then the owner/user etc.

Any help would be greatly appreciated

thanks
 
Something to get you started...

ls -l|awk '/^-/ {
size[$3]+=$5;
files[$3]++;
} END {
printf "%-10s %10s %10s \n", "USER", "FILES", "SIZE";
for(user in files)
if(files[user]>1)
printf "%-10s %10d %10d \n", user, files[user], size[user];
}'|sort -n -k3,3

Tested....

USER FILES SIZE
root 30 5147
frank 3 50660
mary 82 140967
simon 5 212388
joan 41 6875861
 
Ygor

Thanks heaps that is exactly what I need , I've been involved with unix for a few years now but I can never get my head around this scripting thing.

Anyway appreciate your help and your prompt answer.

cheers

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top