Solved

Getting modification dates of files

Posted on 1998-08-08
4
190 Views
Last Modified: 2013-12-25
I have a script, that needs to do a glob() type list, and get not only file names, but their modification dates as well.  I will use this to search through a directory, and delete files that were modified over a day ago.
0
Comment
Question by:7thwave
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1831458
In what language is the script written?
0
 

Author Comment

by:7thwave
ID: 1831459
The script is in perl
0
 
LVL 84

Expert Comment

by:ozo
ID: 1831460
(stat $filename)[9]
is the modification date
-M $filename
is the number of days since it was last modified (at the time the script was started)
0
 
LVL 1

Accepted Solution

by:
RoboBob earned 100 total points
ID: 1831461
#!/usr/local/bin/perl -w
#####################
foreach $file (</put/dir/here/*>) {
    if(-M $file > 1) { unlink($file); }
}

or, do it the easy way, from the command line with find...
find -mtime +1 -exec rm {} \;
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question