So, I am running a command like:

find . -type f -mmin +`olderthan $HOME 30` -exec (some command) {} \;

which all works perfectly well and all, BUT the command I am running  
does not output the name of the file its working on because it is  
assuming that you are passing one file at a time (which I am) and that  
you are clever enough to know which file you just passed (which I'm  
not).

there doesn't seem to be a way to -exec two commands (like echo {} \;  
(some command) {} \;)

I have a sneaking suspicion I asked this once before, but I can't find  
it in my mail archive...

Oh.. olderthan is a very clever bit of perl that I got of the procmail  
list, of all places:

#!/usr/local/bin/perl -w
#
# olderthan
#
# 20080730/1132 SBS     Created
#

use strict;
use warnings;

MAIN:
{
        # process:
        # take first argument from commandline, stat it, convert to  
epoch
        # take second argument, multiply by seconds in a day
        # subtract from stat'd time to establish source date
        # subtract this figure from the current time to get an age
        # emit value expressed in integer minutes.

        die "olderthan: Calculate in minutes the days since  
referencefile was modified\nSyntax:\n$0 referencefile days\n"
                       if (@ARGV != 2);

        my $referencefile = $ARGV[0];
        my $referencetime = $ARGV[1];
        my ($oldtime, $nowtime, $stattime);

        die "$referencefile doesn't exist\n"
                unless -e $referencefile;
        die "$referencetime is not an integer\n"
                if !($referencetime =~ /^-?\d+$/);

        ($stattime) = (stat $referencefile)[9];

        $oldtime = $stattime - ( $referencetime * 60 * 60 * 24 );

        # okay, now get the current time since epoch
        $nowtime = time();

        # age is $nowtime minus $oldtime
        # express it in minutes to stdout
        print( int ( ( $nowtime - $oldtime ) / 60 ) );

#   Done.
}
#EOF

-- 
The person on the other side was a young woman. Very obviously a
        young woman. There was no possible way that she could have been
        mistaken for a young man in any language, especially Braille.

_______________________________________________
OSX-Nutters mailing list | [email protected]
http://lists.tit-wank.com/mailman/listinfo/osx-nutters
List hosted at http://cat5.org/

Reply via email to