A find and sort challenge...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers A find and sort challenge...
# 1  
Old 06-03-2005
Question A find and sort challenge...

Hi,

I need to generate a listing of files that have been changed since x day. the listing is to be sorted by date.

I managed to get the 1st requirement using the find command :
find . -mtime -100 -type f -ls
but I don't know how to sort the ls listing by date. Smilie

The challenge comes when the files that have been changed for a day lies all over the directory. Smilie

Can anyone help ?

A zillion thanks !
Poh

p/s: I'm on Tru64 UNIX; and sort -M is not available...

Last edited by ppohz; 06-03-2005 at 05:50 AM..
# 2  
Old 06-03-2005
Try...
Code:
find . -mtime -100 -type f -print | xargs ls -t

# 3  
Old 06-05-2005
Hi Ygor,

Thanks for the help.
I've tried the command per posted, but I could not see the file details. When I change the -t option to -lt, it gives me a weird listing whereby the output isn't really sorted :

Jun 1 11:08 ./gen/toad_scripts/bkup_c
Jun 1 10:56 ./gen/toad_scripts/tmp_pk
May 30 16:36 ./gl/sqr/bkup_copy/xcuinv
May 30 16:36 ./gl/sqr/bkup_copy/xcuinv
Jan 7 15:48 ./gl/sqr/bkup_copy/cunrvrt
Jan 7 15:48 ./gl/sqr/cunrvrpt.sqr
Jan 7 15:48 ./gl/sqr/cunrvrpt.sqt
Jun 1 11:18 ./.lastlogin
May 13 09:13 ./inv/sql/whse_rcvd_load.l
May 13 09:11 ./inv/sql/bkup_source/whs5
May 3 16:47 ./inv/sql/bkup_source/whsl
Apr 19 10:38 ./oe/com/cuboxdown.com

I'm not sure where the problem lies....
# 4  
Old 06-05-2005
The is because xargs is breaking the list of arguments it is passing to ls into smaller chunks so has not to supply to many args to ls.
# 5  
Old 06-06-2005
This works, though I'm sure there are more graceful solutions out there:
Code:
find . -mtime -100 -type f | tr '\012' ' ' > /tmp/ick && ls -lt < /tmp/ick

Cheers,

Keith

Last edited by kduffin; 06-06-2005 at 02:48 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Linux find jpg and sort by date

I want to find all jpg files and then sort them by modification date. This is where I started. find . -type f -name "*.jpg" I tried to pipe a sort in there but that did not seem to work. Do I need to use xargs? (10 Replies)
Discussion started by: cokedude
10 Replies

2. Shell Programming and Scripting

Find files and sort by timestamp

Used below command to get list of files sorted by timestamp find -L . -type f -name '*dat*' | xargs ls -ltrg I want to get only the filenames so I tried adding basename but it doenst work , can some one advise on how to get only file name (1 Reply)
Discussion started by: lalitpct
1 Replies

3. Shell Programming and Scripting

Find and sort by first column value

Hi, I have two text files file 1 with N lines AAAAA 2.092290E-12 BBBBB 1.727740E-07 CCCCC 9.608710E-17 DDDDD 0.000000E+00 EEEEE 0.000000E+00 FFFFF 0.000000E+00 GGGGG 0.000000E+00 HHHHH 0.000000E+00 IIIII 3.300320E-04 ... The text in the first column is unique for each row and... (4 Replies)
Discussion started by: f_o_555
4 Replies

4. UNIX for Dummies Questions & Answers

sort find results

Hi, I have a problem with a shell script. The script should find all .cpp and .h files and list them. With: for file in `find $src -name '*.h' -o -name '*.cpp' it gives out this: H:\FileList\A\E\F\G\newCppFile.cpp H:\FileList\header01.h H:\FileList\B\nextCppFile.cpp ... (4 Replies)
Discussion started by: shellBeginner75
4 Replies

5. Shell Programming and Scripting

find command with sort

HI Find command is sorting differently in different machines. I am trying a script to find file with -name option and delete the files other and keep the latest. the problem I am facing is in one machine find command is returning output sorted with oldest first and latest . But in another... (1 Reply)
Discussion started by: ningy
1 Replies

6. Linux

System wide find and sort

Hi, I need to look for a config file (ldap.conf) and pick the latest modified file. `locate` tells me there are many ldap.conf's, some in /etc, /usr, /home, etc. Is there some way I can sort them by last modified time via bash? I was thinking maybe I could pipe the output of `locate` to `ls... (4 Replies)
Discussion started by: Housni
4 Replies

7. UNIX for Dummies Questions & Answers

find command sort options?

Hi - are there sort options with the find command? I don't see any in man. I have a script that is looping through a set a files to be processed and I need to process them in date timestamp order. tia for file in `find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN1}` do.... ... (6 Replies)
Discussion started by: mavsman
6 Replies

8. Shell Programming and Scripting

Perl find::file can I sort the out put

Perl file::find can I sort the out put I am using file::find in my script but how I wish to process each file found in date order. Can I sort this module? eg part of current script is.... use File::Find; # Recursively find all files and directories in $mqueue_directory find(\&wanted,... (2 Replies)
Discussion started by: Andrek
2 Replies

9. UNIX for Dummies Questions & Answers

How to sort find results

Hi-- Ok. I have now found that: find -x -ls will do what I need as far as finding all files on a particular volume. Now I need to sort the results by the file's modification date/time. Is there a way to do that? Also, I notice that for many files, whereas the man for find says ls is... (8 Replies)
Discussion started by: groundlevel
8 Replies
Login or Register to Ask a Question