Count files made by given user in Centos

116 views Asked by At

My sessions directory is very large and I would like to count how many files are made by each separate user (each domain).

Is there an option (with ls maybe) to count (not to list) total files made by a given user ?

I know that ls -alh dir_name lists all files and user is on one of the columns.

And also that this counts all files: ls -1 dir_name | wc -l

Maybe command can be adjusted to do a search on the column containig the username, and then count the results?

2

There are 2 answers

0
Donovan On BEST ANSWER

If you know the username, this should work for you.

find dir_name -type f -user 'username' | wc -l
0
ldav1s On

Something like:

 ls -alh dir_name | awk -F " " '{ print $3;}' | sort | uniq -c

is pretty close to what you want.