Re: Command to prune archive at restartpoints
Andrew Dunstan <andrew@dunslane.net>
From: Andrew Dunstan <andrew@dunslane.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>, Greg Stark <gsstark@mit.edu>, Simon Riggs <simon@2ndquadrant.com>, Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2010-06-08T23:07:10Z
Lists: pgsql-hackers
Tom Lane wrote:
> As for the language choice, my first thought is +1 for perl over shell,
> mainly because it might be directly useful to people on Windows while
> shell never would be. On the other hand, if it's possible to do a
> useful one-liner in shell then let's do it that way.
>
I don't think it is, reasonably. But here is fairly minimal version that
might suit the docs:
use strict;
my ($dir, $num) = @ARGV;
foreach my $file (glob("$dir/*"))
{
my $name = basename($file);
unlink $file if (-f $file && $name =~ /^[0-9A-Z]{24}$/ && $name lt $num);
}
cheers
andrew