创建或目录文件
- 该脚本应当有交互功能
- 该脚本用于备份系统目录
- 需要给予用户提示,提示用户应当输入目录或者文件名
- 判断用户要备份的文件是否存在,如果不存在则告知用户,并输出相应错误
- 判断用户要备份的目标目录是否存在,如果该目录不存在,则需要问用户是否创建,如果该目录已经存在,则需要问用户是否重命名该目录
#!/bin/bash
#This is a shell for backup the system dir
read -p "Please input your dir : " dir
read -p "please input your backup file: " file
if [ -e $file ]
then
echo "The $file is already exisit,you do not need make again"
else
echo "This $file is not exsit, please back up it first"
tar -czvf targettar.tar.gz $dir
fi
if [ -e $dir ]
then
echo "This $dir is exsit,are you sure to move this $dir"
else
echo "This $dir is not exsit,please make dir first"
fi