Book Reviews   Digital Libraries   Astronomy Log   Software   About  

Dir::Purge
20 February 2004 02:00

Found a very useful Perl Module today. It's a bit old, but useful nonetheless. Here's the situation: In making backups of certain things I find myself wanting to be able to keep around the N newest files in a certain directory. A simplistic way of doing this is something like

find . -mtime +N -exec rm {} ;

Or something like that. The problem with that is that if, for some reason you fail to make a backup for some number of days, you eventually lose all your backups. So I found Dir::Purge on CPAN which does things a little smarter. It lets you specify how many files you want to keep around, and it's smart enough to keep the N newest (or oldest) files around. Nice. Makes my job easier, and it's code I don't have to maintain. Even better.

So my co-worker also offers a similar 1-liner solution by using a combination of ls -latr, and head or tail. Yeah, that'd probably work too :-).


Comments
Happiness
True love begins when the needs of others become more important than your own.
The practice of true love begets true happiness

Me

Daniel Hanks

I'm a system administrator working for Omniture

Interested in

perl
books
python
databases
genealogy
astronomy
digital archival
digital libraries
web applications
web infrastructure
distributed storage

among other things . . .

Storyteller


Pamela Hanks

is an excellent storyteller.

(She also happens to be my wife :-)

A storyteller makes a wonderful and unique addition to family, school, church or other group events. Schedule her for your next gathering.


Utah Open Source

Kiva.org
Kiva - loans that change lives

Recent Blog Entries

Subscribe with Bloglines
- OpenWest Conference 2014 Presentation Slides - Ansible
- OpenWest Conference 2013 Presentation Slides
- Utah Open Source Conference 2012 - Presentation slides
- E-Book Review: Data Mashups in R
- Book Review: Illustrated Guide to Astronomical Wonders
- Book Review: Wicked Cool Shell Scripts
- PLUG Presentation Slides: The Open Source Data Center
- Harnessing human computational power from computer games
- I love a good roadtrip
- FamilySearch Developers Conference 2008 presentations now available online
- FHT follow up: an idea for a mobile genealogical application
- Family history and technology: it's only getting better
- President Hinckley passes away
- December is NaBoMoReMo - National Book of Mormon Reading Month
- Family History, Photos, Blogs, and Books
- The Compact Oxford English Dictionary
- 1830s English and the Book of Mormon
- Google adds My Library feature to Book Search
- Utah Open Source Conference
- Wiki diagrammer (Steal this idea!)

All Entries . . .

LDSOSS
LDS Open Source Software
A website discussing the use of Open-source software for applications useful to those sharing values of the Latter-day Saint (Mormon) faith.

© 2009, Daniel C. Hanks