备份和恢复配置文件时使用
#!/bin/bash
# backup file
[ -e $1 ] && cp -p $1 $1.`date +%F.%T`.bak && echo -e "\t\t\t\t\t\e[32m OK \e[0m" || echo -e "\t\t\t\t\t\e[31m Failed \e[0m"
#!/bin/bash
# unbackup file
file_name=`echo $1 | sed "s/\.2.*bak$//"`
[ -e $1 ] && mv $1 $file_name && echo -e "\t\t\t\t\t\e[32m OK \e[0m" || echo -e "\t\t\t\t\t\e[31m Failed \e[0m"
本文出自 “hiyang” 博客,请务必保留此出处http://hiyang.blog.51cto.com/10728919/1795085
原文地址:http://hiyang.blog.51cto.com/10728919/1795085