作者: reistlin
来源: http://www.reistlin.com/blog/173
更新时间: 2011.02
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

linux.pngcode.png

#!/usr/bin/perl

# name: cpbak v1.0
# author: reistlin
# website: www.reistlin.com
# date: 2011.02.22

use strict;
use Data::Dumper;
use Time::Local;

# debug switch
my $debug = 0;

my $name = shift;
my $date = `date +%Y%m%d`;

chomp $date;

if ( $name ) {
	my $check = index($name, ".");

	if ( $check == -1 ) {
        	print `cp -a $name $name.$date`;
        	exit;
	} else {
        	$name =~ m/^(.+)\.(.+)$/;
        	print `cp -a $name $1.$date.$2`;
        	exit;
	}
} else {
	exit;
}

标签: perl