How to sort output from find from oldest to newest?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to sort output from find from oldest to newest?
# 1  
Old 07-18-2010
How to sort output from find from oldest to newest?

Hi,

How do I sort the output of find to provide a listing of files from oldest to newest?

For example, if I do a find /tmp -type f -print I want the output to be sorted in the order of the oldest to the newest file.

Thanks in advance.
# 2  
Old 07-19-2010
ls -lrt would show newest at last. and if u want to reverse then simple ls -lt.

using find:
Code:
find /tmp -type f | exex ls -lrt {} \;

# 3  
Old 07-19-2010
Assuming a Posix shell and a moderate number of files:

Code:
ls -1tr $( find /tmp/ -type f -print )

The parameters tp "ls" are hyphen-one-tee-arr . We just want to list the file names in ascending date order.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to sort an output

with a command i get a long list (example) and the entrys are intended. DName=AAAAA DName=AAAAA lba=838,860,800 label=ftw_1 DName=BBBBB DName=BBBBB lba=838,860,800 label=ftw_2 DName=CCCCC ... (3 Replies)
Discussion started by: Serano
3 Replies

2. Shell Programming and Scripting

Find file by filename or with newest modified date

Hi, I have a directory that has numerous files in it, and there is two which are named "filerec_ddmmyyHH24MMSS" by the time they are created so "filerec_010615012250" was created at 01:22:50 on 1st June 2015. I need to find the most recently created of those 2 files and get the contents of... (4 Replies)
Discussion started by: finn
4 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Find the newest file in two directories

Hi i have two directories and files inside them Directory 1: Directory 2: These files are the same but song.mp3 in Directory 1 is newer than song.mp3 in Directory 2, and work.txt in Directory 2 is newer than work.txt in Directory 1. Now is my question. How i can compare these files... (10 Replies)
Discussion started by: Falstaff
10 Replies

4. Shell Programming and Scripting

Sort and output to different files

Hi all! I have a comma delimited file and I'm sorting it based on fields 6, 8 and 10. The following does the job: sort -t, -nk6,10 unsorted.txt -o sorted.txt What I need to do now is to write every row containing same values on fields 6, 8 and 10 to a different file. Any ideas on how to do... (2 Replies)
Discussion started by: Tr0cken
2 Replies

5. Shell Programming and Scripting

Sort output is different with Corn

Hi, I am sorting a file, but getting different output with crontab. input file-file z Z x X y Y when I sort manually sort file x X y Y z Z (4 Replies)
Discussion started by: suresh3566
4 Replies

6. Shell Programming and Scripting

Find Oldest file in a directory tree

This might just be one command. Any1 having the solution? Thanks, Rahul. (25 Replies)
Discussion started by: rahulrathod
25 Replies

7. Shell Programming and Scripting

sort files by date, delete oldest, if total size bigger than

hello people i need your help please i want to achieve the following with the simplest, most efficient shell-tools: i have a directory with a lot of files from users. the script should check which partition the dir is on if the partition with the directory is more than 90% full ... (2 Replies)
Discussion started by: scarfake
2 Replies

8. Shell Programming and Scripting

sort output

this one is a bit tricky: host16 /etc/passwd changed Thu Jan 3 16:39:48 host3 /etc/group changed Thu Jan 3 16:39:48 host2 /etc/services changed Thu Jan 3 16:39:48 host10 /etc/group changed Thu Jan 10 09:59:01 host11 /etc/group changed Thu Jan 3 18:55:38 host17 /etc/group changed Thu Jan... (9 Replies)
Discussion started by: funksen
9 Replies

9. UNIX for Dummies Questions & Answers

how to sort and arrange an output

ok so I have a list of names that end in either ot,om,oa. So for example DETOT MANOA DET0M DET0A MANOT SEAOT etc... I want to be able to group this list by OT, OM, OA and have the output have some headers like this and be alphabatized and if possible be in colums instead of like... (10 Replies)
Discussion started by: llsmr777
10 Replies
Login or Register to Ask a Question