Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting all files that are owned by someone.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0

I need to find all files with the name of the person who owns the file.

ls -l gives me:

-rw-r--r-- 1 smith mygroup 58 Dec 4 2001 zy


I want to get all files that are owned by smith:

find . "smith" -exec ls -l {} \;

This is not working. Any suggestions??
 
I think lancer73 probably means:

find . -user smith -exec ls -la {} \;

as ld will give only directories, la will give all files including 'hidden' ones (eg .profile). Cheers.
 
actually, -a would be a good switch to put in to list . files. however, -d will not list only directories. it will list files as well, and only directory paths. without the -d option you will list the contents of all files in that directory (which may not be owned by that user), and you'll get duplicate listings if files owned by smith are also in directories owned by smith (one listing for the file found, one when the directory contents are displayed). now, if you don't want to list directories, you can use this as an alternative:

find . -user smith -type f -exec ls -la {} \;
 
find . -type d -user smith -ls

will show all directories owned by smith

find . -type f -user smith -ls

will only show files.
 
Are yyou using an xterm window to run these commands. Sorry if it's a stupid question. I'm tryin to learn our new system.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top