Listing latest modified or created files recursively


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Listing latest modified or created files recursively
# 15  
Old 10-05-2012
Quote:
Originally Posted by pamu
But I'll try as per what resources I have.
There may be resources new to you then. Smilie such as find's -printf command, which can print date and time as you want.

Code:
find . -printf "%AY%Am%Ad%AH%AM %p\n" | sort -n | sed 's/^[0-9]* //'

# 16  
Old 10-05-2012
Quote:
Originally Posted by Corona688
There may be resources new to you then. Smilie such as find's -printf command, which can print date and time as you want.

Code:
find . -printf "%AY%Am%Ad%AH%AM %p\n" | sort -n | sed 's/^[0-9]* //'

see the main first post. as he tried using sort that's why i have used this...
# 17  
Old 10-05-2012
Quote:
Originally Posted by pamu
see the main first post. as he tried using sort that's why i have used this...
Garbage in, garbage out. Problem was not with sort but the manner it was being used and the data it was given.

I made find print timestamps in YYYYMMDDHHMM, because dates given in that format always sort perfectly if you put them on the beginning of the line.
# 18  
Old 10-05-2012
Quote:
Originally Posted by Corona688
Garbage in, garbage out. Problem was not with sort but the manner it was being used and the data it was given.

I made find print timestamps in YYYYMMDDHHMM, because dates given in that format always sort perfectly if you put them on the beginning of the line.
That's why i used positional sort. this is as per what i got from find and ls.
# 19  
Old 10-05-2012
Quote:
Originally Posted by pamu
That's why i used positional sort. this is as per what i got from find and ls.
...and we have now come full circle.

"Locale dependent" means "what works for you won't work for someone else". Even worse, it will fail in ways that aren't obvious -- the output will be scrambled or wrong, rather than getting an error message or "option not supported". ls' output on even the same machine can be different for different files. For new files, my version of ls shows dates; for older ones, it shows only years. You can't sort that.

Using find -prinf means you always get exactly what you ask for, no more, no less.
# 20  
Old 10-05-2012
Quote:
Originally Posted by Corona688
...and we have now come full circle.

"Locale dependent" means "what works for you won't work for someone else". Even worse, it will fail in ways that aren't obvious -- the output will be scrambled or wrong, rather than getting an error message or "option not supported". ls' output on even the same machine can be different for different files. For new files, my version of ls shows dates; for older ones, it shows only years. You can't sort that.

Using find -prinf means you always get exactly what you ask for, no more, no less.

Yes. agreed...
but till the time you don't know what is result of the command we can't comment anything. max we can request user to give proper inputs but this never happens.
as i am not master you do expect post like this.Smilie
ps: i m not fighting over which method is good...
# 21  
Old 10-05-2012
Quote:
Originally Posted by pamu
but till the time you don't know what is result of the command we can't comment anything. max we can request user to give proper inputs but this never happens.
Yes, if the user doesn't give information it's very hard to know what their ls output looks like.

You don't have to depend on that, though.
Quote:
ps: i m not fighting over which method is good...
What is your point, then?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Modified or latest files copy from windows to Linux

To copy the file from windows to linux i use pscp command(pscp source user@destination). Know i want to copy the latest modified or created files from windows to linux. could any one please help me out with it. Thanks and Regards, Sourabh (2 Replies)
Discussion started by: SourabhChavan
2 Replies

2. Shell Programming and Scripting

Listing the file name and no of records in each files for the files created on a specific day

Hi, I want to display the file names and the record count for the files in the 2nd column for the files created today. i have written the below command which is listing the file names. but while piping the above command to the wc -l command its not working for me. ls -l... (5 Replies)
Discussion started by: Showdown
5 Replies

3. UNIX for Dummies Questions & Answers

To find the latest modified file in a directory

I am trying to fetch the latest modified file from a directory using the command find . -type f -exec ls -lt \{\} \+ | head | awk '{print $9}' After the O/P, I get the below mentioned error and the command doesnt terminate at all. find: ls terminated by signal 13 find: ls terminated by... (2 Replies)
Discussion started by: Sree10
2 Replies

4. Shell Programming and Scripting

Listing latest & large files from a mounted drive

Hi All, My AIX server have a mounted drive "/stage". I want to list the latest modified/created files in this drive. Also large files in this drive. I tried to ls -l | sort +4nr | head -10 Someother solutions to list from entire drive. Thanks. :) (6 Replies)
Discussion started by: karumudi7
6 Replies

5. UNIX for Dummies Questions & Answers

Recursively listing of the file

Hi, I want to list out the files for a particular date recursively along with timestamp and directory name . I tried using command ls -lRt this list out all the files along with directory structure but i want for a particular date so i tried with ls -lRt | grep 20110809 in... (9 Replies)
Discussion started by: Abhi2910
9 Replies

6. Shell Programming and Scripting

to pick the latest file modified in a directory

I wan to pick the latest modified file name and redirect it to a file .. ls -tr | tail -1 >file but this is printing file ins side the filename , can anyone help me out (5 Replies)
Discussion started by: vishwakar
5 Replies

7. UNIX for Dummies Questions & Answers

How to get the latest modified file name in /home directory?

I only know how to list all sub-directories or files in specified directory. I don't know how to order them by modified date, furthermore, I don't know how to get the top one file in the sorted list. Wish you can do me a favor. Thanks in advance! (3 Replies)
Discussion started by: crest.boy
3 Replies

8. Shell Programming and Scripting

Find the directory modified/created before 4 days

Hi, I have an application which creates some directories while running. I want to delete these directories which are 4 days older. i tried find . type d -mtime +1 -print And it is working fine.. but find . type d -mtime +4 -print is not giving any results which are 4 days... (6 Replies)
Discussion started by: Tuxidow
6 Replies

9. Shell Programming and Scripting

How can i search a file which has been created or modified in last five minutes

Hi Can some one please help me How can i search a file which has been created or modified in last five minutes I have used the command find . -mmin -5 and it does not work i get an error -mmin is bad option Please help Much regards Tarun (2 Replies)
Discussion started by: tarundeepdhawan
2 Replies

10. Shell Programming and Scripting

List Files & Folders created/modified

Hello people, I want to list the files & folders created/modified since a particular date say June 2006. I know I can list recursively thru the folders and use awk to extract the date column to get the desired output. Just wanted to check whether there is an easier way to do this. Please... (2 Replies)
Discussion started by: tipsy
2 Replies
Login or Register to Ask a Question