标签:交互脚本
#!/bin/bash read -p "input the source file or directory you want to backup(absolute path): " sour if [ ! -e $sour ]; then echo "the source file or directory not exits.the script is end." exit 1 fi read -p "input the targe filename or directoryname(absolut path): " tar if [ -e $tar ]; then echo "the target is exits" read -p "do you need to rename?(yes|no)" yn case $yn in yes|y) read -p "input the new name(absolut path): " newname mv $tar $newname cp -r $sour $tar echo "backup success" ;; no|n) if [ -d $tar ]; then cp -r $sour $tar echo "backup success" else echo "can not backup" exit 2 fi ;; esac else tdir=`dirname $tar` mkdir -r $tdir &> /dev/null cp -r $sour $tar echo "backup success" fi
标签:交互脚本
原文地址:http://chomper.blog.51cto.com/7866214/1684506