?
Solved

Getting modification dates of files

Posted on 1998-08-08
4
Medium Priority
?
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

801 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