Find the list of files with a set of Users

Hello all,

I want to find the files for certain users. I cant make the or condition work in this instance. I've tried the code below but it didnt worked. Any input on how to get the list for all files for this users.

 
find . -type f -user abc134 -o -user xyz345 -o bce483 -exec ls -ltr {} \;

Regards,
Seth

find . -type f \( -user abc134 -or -user xyz345 -or bce483 \) -exec ls -ltr {} \;

You may need to bracket the or conditions, else you end up matching all sorts of things.

Try:-

find . -type f \( -user abc134 -o -user xyz345 -o bce483 \) -exec ls -ltr {} \;

and see if that helps.

Robin

Just to add that I don't see how ls -tr could be useful in this context :slight_smile:

Yes, I agree, I never looked at that bit.

If you want files in that format, you will have to push it out of the find command more like this:-

ls -lrt `find . -type f \( -user abc134 -o -user xyz345 -o bce483 \)`

It's probably bad programming practice as the command line might get too long. Here's an alternate:-

find . -type f \( -user abc134 -o -user xyz345 -o bce483 \) | xargs ls -lrt

....but that might not work for lots of files as it breaks the input into manageable chunks so you will get several runs of ls -lrt with lots of files. You could therefore get several blocks of output sorted, but there will not be a delimiting line between them.

Robin

Yes.
On some GNU systems one may use something like this:

find ... -printf '%TY/%Tm/%Td %TT %p\n' | sort  -k1,2nr

As always - it depends, but on non-GNU systems I would probably use Perl for this task.
EDIT: Just noticed that some find implementations have the -ls option, so the list could be sorted by modification time.

Thank-you all. Its working for me now. !!