[prev in list] [next in list] [prev in thread] [next in thread] 

List:       aix-l
Subject:    Re: [Q] find old files and sort it?
From:       Ross Alexander <ralexan9 () telusplanet ! net>
Date:       2003-04-24 16:28:23
[Download RAW message or body]

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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic