trying to find a way to locate files modified in the last hour in a shell script, unfortunately the command 'find . -mmin -60' is not supported on SunOS 5.10 (works on OpenSolaris 5.11 )
Does anyone know a method of doing this in shell script on 5.10?
I don't understand how to integrate your perl code into a shell script rad, can you give an example? i.e. switching to the directory /richard/share then listing all files in there modified in the last hour?
which does the actual test to see if it's less than 1 hour? I take it the 1 relates to 1 hour?
when i run it against my directory it shows files which have been modified over an hour ago?
function SearchLogsLastHour
{
cd $URS_LOGS
filenames="$(
perl -MFile::Find -le'
find {
wanted => sub {
-f and 1 >= -M and print $File::Find::name;
}
}, shift
' /export/home/richard/share/ipcc/urslogs
)"
echo $filenames | ls -l
}
When i run the above it just shows all the file in the directory - I opened and saved one of them, ran it again (expected it to just list the one file I saved a few seconds ago) but it still lists all the files the directory
---------- Post updated at 08:11 PM ---------- Previous update was at 07:25 PM ----------
so say the perl program finds 3 files matching the critera - is there an easy way to modify this so that once the first file is found, we do a grep on that file then output what we need to the temp file, then proceed to the second file, do a grep on that, output to the temp file etc etc?
cd $LOGS
filenames="$(
perl -MFile::Find -le'
find {
wanted => sub {
-f and 1 / 24 >= -M and print $File::Find::name;
}
}, shift
' /export/home/richard/logs
)"
grep "cheese" $filenames
That seems to work, but I need to introduce an IF into it so that if the perl returns any files of the extension .gz it does a gzgrep instead of a normal grep