Question

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?

Was it helpful?

Solution

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

find dir_name -type f -user 'username' | wc -l

OTHER TIPS

Something like:

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

is pretty close to what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top