Results 1 to 4 of 4
Hi,
I have a dir with loads of files and sub-directories, owned by different users and
I wanted to generate a list of the summarized file-sizes by owner.
I tried ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-14-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 3
view disc-usage by owner
Hi,
I have a dir with loads of files and sub-directories, owned by different users and
I wanted to generate a list of the summarized file-sizes by owner.
I tried something like:
find . -print0 -type f -user someuser > tmp
du -sh --files0-from=tmp
but I get just a bunch of crap.
How can I do this?
- 11-15-2007 #2
I'd use a combination of ls -l and awk. For example
will print out the total disk space for files owned by name in directory. You can tweak the program so that it prints out the data you want.Code:ls -l directory|awk '$3~name{total=total+$5};END {print total}'"I'm just a little old lady; don't try to dazzle me with jargon!"
- 11-16-2007 #3Just Joined!
- Join Date
- Oct 2007
- Posts
- 3
Works perfectly, thanks!
tweaked it to something like:
Code:ls -lR /somedir/ | awk '$3~"user1"{total1=total1+$5} $3~"user2"{total2=total2+$5};END {print "user1: " total1 "\nuser2: " total2 }'
- 11-24-2007 #4Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
Wrap your command in a for loop and cater for all names present:
Code:for name in $(ls -l /somedir | awk '{print $3}' | sort -u) do echo $name # (your counting command here) done


Reply With Quote
