Say you have a directory with a bunch of sub directories and files and you want to see if all the files are owned by a particular user, you can use the following set of commands
[code]ls DIRECTORY_PATH -l -R | awk {‘print $3’} | grep -v USER_NAME[/code]
The set of commands do the following
- ls -l -R shows the list of files and directories
- awk prints the name of the owner of the file (it is the third column)
- grep shows only the lines where the owner name doesn’t match
And yeah.. this works in most variants of Linux :).
Incase if you wish to find the total size owned by a particular user, please use this syntax:
http://ashok-linux-tips.blogspot.com/2010/12/finding-total-size-of-files-owned-by.html
Thanks !
very nice.. Thx Ashok.
– V