Find user owner of the most recently file in the system


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find user owner of the most recently file in the system
# 1  
Old 06-18-2010
Find user owner of the most recently file in the system

Good evening everybody,
I have to find the user owner of the most recently file in the system
How can I do? Smilie
# 2  
Old 06-18-2010
Use the search function, there are a lot of threads regarding this topic:

Google Search Results for most recent file | The UNIX and Linux Forums
This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 06-19-2010
I have solved in this way:

Code:
find / -type f | xargs ls -alrt | cut -f 2 | tail -n 1

The output is:

Code:
-rw------- 1 root  operator    7111  Jun 18 22:01 /root/.viminfo

How can I obtain from this output only the owner of this file?[COLOR="#738fbf"]

---------- Post updated at 02:49 AM ---------- Previous update was at 02:47 AM ----------

Solved SmilieSmilieSmilieSmilie

Code:
find / -type f | xargs ls -alt |  tail -n 1 | awk '{print $3}'


Last edited by Guccio; 06-19-2010 at 06:14 AM..
# 4  
Old 06-19-2010
Hi, that would work as long as there are no spaces in the filenames, otherwise you could use something like this if your find supports print0:
Code:
find / -type f -print0 | xargs -0 ls -alt | awk 'NR==1{print $3}'

(my ls -alt has the owner in the third column)

or this if it supports printf:
Code:
find / -type f -printf "%A@ %u\n" | sort -rn | awk 'NR==1{print $2}'


Last edited by Scrutinizer; 06-19-2010 at 07:17 AM..
# 5  
Old 06-19-2010
Ok but the problem is to find user owner most recently file in the system

If this user is "bin" ?

My solution find it!
# 6  
Old 06-19-2010
Code:
find / -type f -user bin -print0 | xargs -0 ls -art1 | tail -1

or
Code:
find / -type f -user bin -printf "%A@ %p\n" | sort -rn | awk 'NR==1{print $2}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find the owner user of each folder in a list

Hello I have a file containing the list of different folders like this file_list.txt: /s8/tests/test1 /s8/tests/tests/test2 /s8/tests/test2 /s8/tests/tests/test2/test5 I want a script to put the owner user of each folder in front of it in the text file. So the reult would become... (5 Replies)
Discussion started by: Johanni
5 Replies

2. Solaris

Privileges : modify dir/file owner by other that's not owner

i need to do the following operations in solaris 10: 1.change owner and group owner for files which are not owned by the current user and user group 2.to can delete files in the /tmp directory which are not of the current user 3. allow to a standard user the deletion of files in the /tmp... (1 Reply)
Discussion started by: sirmark
1 Replies

3. Shell Programming and Scripting

find a user on the system

i am prompting for a name to search. read user if then however, i get this error: please enter a username on the system: fool menu_script2.sh: line 123: (4 Replies)
Discussion started by: icelated
4 Replies

4. UNIX for Dummies Questions & Answers

Find recently changed files

Hi, Can you guys tell me how do i find the most recently changed files, say an hour before, few hours before, a day before etc.... Thanks!!!! (3 Replies)
Discussion started by: raghu_shekar
3 Replies

5. Shell Programming and Scripting

Find the user with less number of files in the system

Good morning everybody, I'm using Minix and I want to find the user with less number of files in the system I have tried this solution: #! /bin/sh indice=0 listaCut=$(cut -f 3 -d : /etc/passwd) for USER in $listaCut; do cont=0 listaFind=$(find / -user "${USER}" -type -f) ... (4 Replies)
Discussion started by: Guccio
4 Replies

6. Ubuntu

How can we find out who are all logged out recently?

Hi, I need to find out who are all the users logged out recently or some minutes or some hours ago. :b: (4 Replies)
Discussion started by: balan_mca
4 Replies

7. UNIX for Dummies Questions & Answers

Find most recently modified directories

How do I do it? Simple answers preferred... using BASH.. the less code the better. I want to find out where Indesign is caching PDF tmp data ... I figure this is a good way to do it.. either way i wanna know how to do it. (2 Replies)
Discussion started by: glev2005
2 Replies

8. Shell Programming and Scripting

find recently modified/ updated file

hi gurus, i would like to know how can i find logs files which were recently modified or updated? :confused: using this command? find . -name "*.log" -mtime ?? so what should i put for mtime? thanks. wee (9 Replies)
Discussion started by: lweegp
9 Replies

9. UNIX for Dummies Questions & Answers

How to know owner of a file without ls and find command

How to know owner of a file without ls and find command :p (1 Reply)
Discussion started by: swat
1 Replies

10. Solaris

Owner of file gets 'not owner' error for chgrp

Hi Folks, I know that changing users and groups is pretty basic admin, but this one has got me stumped. When I try to change the group of a file for which I am the owner for, it still gives me a 'Not owner' error. For example, when I am logged in as 'webadmin', I have the following file: ... (4 Replies)
Discussion started by: brizrobbo
4 Replies
Login or Register to Ask a Question