The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-20-2003
lcfoo lcfoo is offline
Registered User
  
 

Join Date: Oct 2002
Location: Malaysia
Posts: 14
Unhappy How to find 1 day old file on Windows for Active Perl

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?
  #2 (permalink)  
Old 02-20-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
I'm confused.. are you asking how to find a file using the Windows operating system or how to find a file using the Perl programming language?

If it's Windows, then which version?
  #3 (permalink)  
Old 02-20-2003
dangral dangral is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2002
Posts: 698
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"
  #4 (permalink)  
Old 02-20-2003
lcfoo lcfoo is offline
Registered User
  
 

Join Date: Oct 2002
Location: Malaysia
Posts: 14
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.
  #5 (permalink)  
Old 02-21-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
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;
If you want to search an entire drive, replace C:\/WINDOWS/Temp/ with C:\\

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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0