开发者

How can I recursively delete all .svn directories using Perl?

开发者 https://www.devze.com 2022-12-11 15:00 出处:网络
What would a Perl script look like that would take a directory, and then delete all .svn di开发者_运维问答rectories in that directory recursively?

What would a Perl script look like that would take a directory, and then delete all .svn di开发者_运维问答rectories in that directory recursively?

(No shell, cross platform)


You can (and probably should) use svn export in the first place.

Otherwise, use File::Find and File::Path::rmtree:

#!/usr/bin/perl

use strict; use warnings;

use File::Find;
use File::Path qw( rmtree );
use File::Spec::Functions qw( catfile );

find(\&rm_dot_svn, $_) for @ARGV;

sub rm_dot_svn {
    return unless -d $File::Find::name;
    return if /^\.svn\z/;
    rmtree(catfile $File::Find::name, '.svn');
    return;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消