13.
corelist
find
corelist v 5.8.8 | egrep i file|find
corelist v 5.8.8 | egrep i opt
Hokkaido.pm #4
14. (1/3)
!!
#!/usr/bin/perl
use warnings;
use strict;
use utf8;
use Getopt::Long;
use Pod::Usage;
use File::Find;
use File::stat;
BEGIN { binmode STDOUT, ':utf8; }
#
my $modified_time = 6;
GetOptions( 'mtime=i' => $modified_time, ) or
pod2usage(2);
my $base_dir = shift @ARGV;
if ( !defined $base_dir ) {
print "n";
pod2usage(2);
}
# bak
find( &delete_files, $base_dir );
Hokkaido.pm #4
15. (2/3)
sub delete_files {
my $fullpath = $File::Find::name;
my $filename = $_;
# bak
return if $filename !~ m{.bak$}xms;
# n
my $stat = stat($fullpath);
my $mtime = $stat->mtime;
return if $mtime + $modified_time * 3600 > time;
#
my $ret = unlink $fullpath;
if ( $ret < 1 ) {
print STDERR "$fullpathn";
return;
}
print "$fullpathn";
}
Hokkaido.pm #4
16. (3/3)
__END__
=encoding utf-8
=head1 NAME
delete_backup_files - n
=head1 SYNOPSIS
delete_backup_files [options] directory_name
Options:
--mtime=n n 6
Hokkaido.pm #4
17.
touch
touch t MMDDhhmm
. hoge.txt 2/10 10:30
touch t 02101030 hoge.txt
Hokkaido.pm #4