How to 'ls' files created within a given time range?

How to 'ls' files created within a given time range?

Post by si.. » Thu, 13 Aug 1998 04:00:00

> In VAX/VMS, one could easily get a listing of files created/modified/accessed


Quote:> before or since a given time period.  I tried all kinds of things with 'ls'
> and it doesn't appear to be a straightforward solution.  How could this be
> done in a little utility script?

find {dirname} -ctime +5
        finds files under {dirname} that were created 5+ days ago

find {dirname} -ctime -5
        finds files under {dirname} that were created less than 5 days ago

find {dirname} -ctime 5
        finds files under {dirname} that were created 5 days ago

find *          - find files here

find * -prune   - fine files in this dir, don't go down dir trees.

        find * -prune -ctime +4 -ls

        might do the trick


Simon Travaglia,  Email without auto spam rejection at by removing the Ph: +64 7 838-4709 Fax: +64 7 838-4066
  University of Waikato, Private Bag 3105, Hamilton, New Zealand..


1. 64k files in dir - 'ls' slow but 'strace ls' fast?

        OK, riddle me this...

        I have a directory with 64,000 files in it.  They're all zero-
length regular files in an ext2 filesystem on a SCSI hard drive, nothing
unusual.  But check this:

chindi:/tmp/manyfiles$ time ls
(snip list of file)
real    7m37.655s
user    0m2.640s
sys     6m20.450s

        Ouch!  That's /slow/.  Let's see why it's slow:

chindi:/tmp/manyfiles$ strace -c ls
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 85.15    0.321233          50      6400           write
 13.65    0.051490         107       482           getdents
  0.44    0.001653           8       217           brk
------ ----------- ----------- --------- --------- ----------------
100.00    0.377256                  7380         2 total

        0.4 SECONDS?!  Something is obviously very different here, but
what?  Amusingly enough, the strace manpage says "A traced process runs


If mail to me bounces, try removing the "+STRING" part.

2. keyboard scancode

3. Why does 'ls' give '/' as the output?

4. Why sez "bash: /dev/null: Permission denied" ???

5. KDE and RH5

6. 'ls -e' vs 'ls -l'

7. PPP Problems

8. Odd Solaris problem: file is seen by 'vi' but not 'ls' ???

9. giving a 'lpr' command from within a C program

10. how to get 'fd' given only 'FILE *' ?

11. formatting ls's output to create script files

12. Existing file can't be seen with 'ls'