Solved

Getting modification dates of files

Posted on 1998-08-08
4
191 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
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 lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

828 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