一个同步所有网站的shell脚本
侧边栏壁纸
  • 累计撰写 186 篇文章
  • 累计收到 24 条评论

一个同步所有网站的shell脚本

五好
2017-04-27 / 0 评论 / 962 阅读 / 正在检测是否收录...

背景:网站由a/b开头命名,实现的功能为 根据用户输入: 网站的类型,原文件的路径,复制到文件的目录,达到同步的目的,对用户输入做了是否是目录/文件的基本检查,如果条件不满足则给予提示信息。

cd /home/www #进入目标目录
    echo "please input enter site type:(a/b)" #提示用户输入网站类型
read type
if [ "$type" == "" ] #判断用户输入的类型,如果为空则为所有网站否则为指定类型的网站
then
type="*"
fi
echo "please input need to copy files path:" #提示用户输入源文件的地址
read file
if [ -f "$file" ]#作出是否是文件的判断
then
echo "please input site path:"#提示用户输入要复制到的目录
read path
ls=`ls -d $type.www.*`#得到/home/www下指定的目录
#for dir in `find -type d -name "a.*" -o -name "b.*"`
for dir in $ls
do
if [ -d "./$dir/$path" ]#对目录做检查
then
echo "cp $file ./$dir/$path" #执行复制,,,
else
        echo "sorry you enter the path is not path"#错误提示信息
fi
done
else
        echo "sorry you enter the file is not file"#错误提示信息
fi
0

评论 (0)

取消