Re: [Q] find old files and sort it?

From: Ross Alexander (ralexan9@telusplanet.net)
Date: Thu Apr 24 2003 - 12:28:23 EDT


On Thu, 24 Apr 2003, L wrote:

> We have IBM AIX 4.3.3. I wrote a script try to find all files (include
> sundirectories) and list it date (reverse order). The script did work
> correct. Can anyone give me a hint?
>
> find /apps/dir1 -mtime +30 -exec ls -lt {} \;

First cut:

        find /apps/dir1 -mtime +30 -print |\
                xargs ls -ltrd

However, as soon as there are more than LINE_MAX characters worth of
file names you're going to get multiple invocations of `ls -ltrd' and
the results will no longer be properly sorted.

Second cut:

        find /apps/dir1 -mtime +30 -print |\
                xargs ls -ltrd |\
                        sort -kXX

but I leave getting the proper values of `-kXX' as an exercise for the
student :) as it is localization dependant.

regards,
Ross

--
Ross Alexander
(780) 975 3505 cell / (780) 433 6725 home
ralexan9@telusplanet.net


This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:46 EDT