![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Active windows when pointed. | rimser9 | UNIX Desktop for Dummies Questions & Answers | 1 | 07-14-2008 03:07 PM |
| Find/replace to new file: ksh -> perl | McLan | Shell Programming and Scripting | 1 | 05-16-2008 03:14 AM |
| perl - how do i find out if a file doesn't contain a pattern? | mjays | Shell Programming and Scripting | 4 | 09-19-2007 06:28 AM |
| Connecting Solaris 9 to Windows Active Directory | morphous | SUN Solaris | 0 | 03-28-2006 05:15 PM |
| How to Unite Redhat 9 Linux with Windows 2003 Active Directory authentication | solaris8in | Linux | 0 | 11-28-2005 08:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to find 1 day old file on Windows for Active Perl?
Is there anyone know the method? If UNIX or LINUX, we can use the "find ...". How to we do for Windows? |
|
||||
|
If you go to start-->find(or search if it's xp), you can choose advanced search, and specify x days ago.
If you are tring to do it through Perl, from Orielly's Learning Perl: "The Perl operator -M returns the age in days since a file or filehandle has last been modified" |
|
||||
|
Sorry for the confusion.
When we use Perl running in UNIX, we can use the below command to search the one day old file. @Files = qx/find . -name '*' -mtime -1 -print/; The problem I am facing now is I am trying to do the same thing but under Windows platform through Active Perl (window based). I have tried using windows, but it seems the script will be very long because you need to capture the last date modified file and compare the date with current date. Is there any other solutions? It is much better if I can use 1 line of command like UNIX (eg. find) on the Window based Perl. Thank you. ![]() |
|
|||||
|
I created a small perl script .. see if it works for you:
Code:
#!C:\Perl\bin\perl.exe
use File::Find;
my @oldFiles;
print "Content-type: text/html\n\n";
find(\&cleanup, "C:\/WINDOWS/Temp/");
sub cleanup {
my $daysOld = ((time - +(stat($_))[9]) / 86400);
if (/\./ && $daysOld >= 1 && $daysOld < 2) {
push(@oldFiles, $File::Find::name);
}
}
print @oldFiles;
References: http://techupdate.zdnet.co.uk/story/...122110,00.html http://techupdate.zdnet.co.uk/i/z/tu...inga110902.htm http://www.xav.com/perl/lib/Pod/perlfunc.html#item_stat |
| Sponsored Links | ||
|
|