shell递归下载repo网站文件
2016-04-14 13:16
603 查看
#!/bin/bash # ---------------------------------------------------------------- # Filename: recursive_down_repo.sh # Revision: 1.0 # Date: 2016-04-14 # Author: Seth # Email: seth@9ishell.com # website: www.9ishell.com # Description: 递归下载repo网站文件 # ---------------------------------------------------------------- bashPath="http://mirrors.aliyun.com/aliyunlinux/15.01/os/x86_64/" bashDownPath="/opt/aliyunlinux/15.01/oss/x86_64/" if [ ! -d $bashdownpath ]; then mkdir -p $bashdownpath fi function recursive_down() { echo "当前网址路径:"$1 list=`curl $1 | grep href | awk -F '"' '{print $2}' | grep -v "^\."` for l in $list do full=$1$l #判断是否为目录,为目录则递归调用 #获得下载路径 downPath=`echo $full | sed "s#$bashPath#$bashDownPath#"` if [[ $l =~ "/" ]] then #递归调用 recursive_down "$full" else #创建下载目录 if [ ! -d $downPath ]; then mkdir -p $downPath fi #获取文件名 filename=$(basename "$full") #判断是否存在文件,不存在即下载 if [ ! -f "$downPath$filename" ];then echo "正在下载$full 到 $downPath" wget $full -P $downPath fi fi done } recursive_down $bashPath
相关文章推荐
- -bash: rz: command not found
- windows azure powershell登录方式
- 高级bash脚本编辑
- gitshell同时用于github与gitlab
- Shell升级,/bin/bash版本号4.1到4.3
- Linux下Bash编程之算术运算符详解(三)
- ssh远程登陆linux显示-bash-4.1$解决方法
- bash脚本笔记随记
- SHELL笔记之管家
- Linux下文件 ~/.bashrc 和 ~/.bash_profile 和 /etc/bashrc 和 /etc/profile 的区别 | 用户登录后加载配置文件的顺序
- learning bash-chap 01
- Windows客户端 SSH 远程连接Windows服务器(PowerShell Server)
- shell 删除奇数偶数行
- .bashrc 大数据版个人配置
- shell脚本学习笔记 (流编辑器sed)
- hbase shell基础和常用命令详解
- 数据库七天自动备份(shell)
- shell 中的特殊符号的含义
- 王高利:shell下使用find xargs grep查找文件及文件内容
- Linux Shell脚本教程