#!/bin/bash
#######################################################################
#This script will automatically backup your file to the fixed directory
#when you edit your file.
#Version 1.0\2009-11-01\by LuoZhongxian
#You can email all your questions to .
#######################################################################
function auto_backup()
{
Dst_dir="`pwd`/BK"
Timestamp="`date +%Y%m%d_%k%M`"
if [ -d $Dst_dir ];
then
Dst_dir="`pwd`/BK"
else
mkdir $Dst_dir
fi
cp $1 $Dst_dir/${1}.bak.${Timestamp}
S=$?
if [ $S -eq 0 ];
then
echo "$1 is copied to $Dst_dir/${1}.bak.${Timestamp}"
else
echo "Copy is faild!"
fi
}
auto_backup $1
exit 0
这个脚本可以自动备份文件,当在一个比较大一点的程序中调用这个函数时,比较有用,不用手动备份。
阅读(663) | 评论(0) | 转发(0) |