[PLUG] count files owned by each uid

Paul Heinlein heinlein at madboa.com
Fri Dec 15 20:41:08 UTC 2017


On Fri, 15 Dec 2017, Galen Seitz wrote:

> Hi,
>
> Can anyone suggest a quick way to get a count of the number files 
> owned by each uid, or alternatively, print each unique uid that 
> exists in the filesystem?  Bonus points for doing the same thing for 
> gid's in the same pass.

Quickly? Probably not. I suppose there's a quota scheme that might 
keep track of such data, but I've never really investigated it.

Less quickly:

sudo find / -type f -exec stat -c '%u:%g' {} \; > /tmp/filedb.txt
# user file count
cut -d: -f1 /tmp/filedb.txt | sort | uniq -c
# group file count
cut -d: -f2 /tmp/filedb.txt | sort | uniq -c


>
> thanks,
> galen
>

-- 
Paul Heinlein
heinlein at madboa.com
45°38' N, 122°6' W


More information about the PLUG mailing list