Find the list of files with a set of Users


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Find the list of files with a set of Users
# 1  
Old 06-21-2013
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.



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


Regards,
Seth
# 2  
Old 06-21-2013
Code:
find . -type f \( -user abc134 -or -user xyz345 -or bce483 \) -exec ls -ltr {} \;

# 3  
Old 06-21-2013
You may need to bracket the or conditions, else you end up matching all sorts of things.

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

and see if that helps.



Robin
# 4  
Old 06-21-2013
Just to add that I don't see how ls -tr could be useful in this context Smilie

Last edited by radoulov; 06-21-2013 at 12:39 PM..
# 5  
Old 06-21-2013
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:-
Code:
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:-
Code:
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
# 6  
Old 06-21-2013
Yes.
On some GNU systems one may use something like this:
Code:
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.

Last edited by radoulov; 06-21-2013 at 01:28 PM..
# 7  
Old 06-21-2013
Thank-you all. Its working for me now. !!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies

2. UNIX for Advanced & Expert Users

Advance file_name serech from set of list files in particular directory

Hi All, im hav one requirement, let me explain my requirement. my script will run every one hour and it wil pull files from remote server to my local server.but the d files hwich are pulled my not be in required format wht im expecting in my server. but in my sever in particular dierectory i... (7 Replies)
Discussion started by: Seshendranath
7 Replies

3. UNIX for Dummies Questions & Answers

Find a set of files in a location

Hi, I am new to Unix. I need a script to check some 74 files are present in a particular location or not . (4 Replies)
Discussion started by: nid21
4 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Using w; how to list find all the users

Hi, On my system, I have about 75 users. Some uers have two or three sessions on the same systems. when I do w, it shows all the sessions. Is there any way to find only the users and not worry about how many sessions. For example: you can see sshe has four connection. I only want to know... (5 Replies)
Discussion started by: samnyc
5 Replies

5. Shell Programming and Scripting

Find Set of files

All, I am trying to find a set of files, it could be one file OR set of file , all with extension .DAT I need to do some acticity, only if the files exist in a partificular folder like if ; then CntV=`ls $Landing/*.DAT |wc -l` echo "Lst Value " $Cnt... (3 Replies)
Discussion started by: Shanks
3 Replies

6. Shell Programming and Scripting

find list of files from a list and copy to a directory

I will be very grateful if someone can help me with bash shell script that does the following: I have a list of filenames: A01_155716 A05_155780 A07_155812 A09_155844 A11_155876 that are kept in different sub directories within my current directory. I want to find these files and copy... (3 Replies)
Discussion started by: manishabh
3 Replies

7. Shell Programming and Scripting

spilit the list of files in set ls -1 *.dbf

Dear All, Please help in this subject.. my requirement is list the files in directory and out of that list make the different set and each should set contains 10 files and assign to variable and start zipping in background. pick the second set files and same to be repeat the commands parallel. i... (3 Replies)
Discussion started by: nmadhuhb
3 Replies

8. UNIX for Dummies Questions & Answers

How do i find out the list of users whose terminal is writable?

Hello, i just wanted to know how do i find out the list of users whose terminal is writable?i mean i used who -T but this gives a list of all users whose terminal is writable or blocked and not writable. So how do i do this?I am new to Unix. (2 Replies)
Discussion started by: salman4u
2 Replies

9. UNIX for Dummies Questions & Answers

Find users using system(List them only once)

Hey, got a few questions here for anyone who can help...... Command line to - display users using the system, but count them only once. Command line to - use the lastcomm command to display how many times ive used grep in october. Command line to - list all logged on users with at least 6... (3 Replies)
Discussion started by: xBuRnTx
3 Replies

10. UNIX for Dummies Questions & Answers

su - user... how to find out the list of users and their passwords..

hi, to do a su - user, we need to know what are the users... so in unix 1) which file to see the list of users, passwords? (2 Replies)
Discussion started by: yls177
2 Replies
Login or Register to Ask a Question