#!/usr/bin/perl use strict; use warnings; =pod =head1 NAME vox-tidy - remove old output files =head1 SYNOPSIS vox-tidy YYYY-MD =cut sub rmdir_current( $ ); sub rmdir_interactive( $;$ ); sub rmdir_report( $ ); our $y4md; { use Pod::Usage qw( pod2usage ); $y4md = shift; defined $y4md or pod2usage( -verbose => 1 ); # and exits # my $in_dir = '/home/v/votorola/in/vomir'; my $out_dir = '/home/v/votorola/out'; rmdir_report( "$out_dir/votrace" ); # rmdir_interactive( "$out_dir/volist" ); # rmdir_current( "$in_dir/natA" ); # rmdir_current( "$in_dir/natP" ); # rmdir_current( "$in_dir/natW" ); rmdir_report( "$out_dir/vocount" ); } # ---------------------------------------------------------------------------------------- sub rmdir_current( $ ) { my $dir = shift; rmdir_interactive( $dir, "current" ); } sub rmdir_interactive( $;$ ) { my $dir = shift; my $snap_name = shift; print( "\n" ); my $command = ""; if( defined $snap_name ) { my $snap_link = "$dir/_snap_$snap_name"; $command .= "ls --color -l --no-group $snap_link; "; } my $dirs = "$dir/snap-$y4md*"; $command .= "ls --color -d $dirs; rm -rI $dirs"; system $command and die 'unable to execute: ' . $command; } sub rmdir_report( $ ) { my $dir = shift; rmdir_interactive( $dir, "report" ); }