Solved

Getting modification dates of files

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now