您现在的位置是:网站首页> 编程资料编程资料
使用curl递归下载软件脚本分享_linux shell_
                     2023-05-26
                347人已围观
                
                2023-05-26
                347人已围观
            
简介 使用curl递归下载软件脚本分享_linux shell_
复制代码 代码如下:
#!/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
clear
Url="http://mirrors.cnnic.cn/apache/"
DownListFile="/tmp/downlist.txt"
DownListTmpFile="/tmp/tmplist.txt"
DownFileType="zip$|gz$"
DownList=""
UrlBack="$Url"
[ ! -f $DownListFile ] && touch $DownListFile || echo > $DownListFile
[ ! -f $DownListTmpFile ] && touch $DownListTmpFile || echo > $DownListTmpFile
CURL_URLS(){
Urls=`curl $UrlBack |awk -F "a href=\"" '{printf "%s\n",$2}'|awk -F "\"" '{printf "%s\n",$1}'|grep -vE "^$|^\?|^http:\/\/"|^#`
}
URL_LIST(){
CURL_URLS
for i in $Urls ;do
echo "$UrlBack$i" >> $DownListTmpFile
done
}
RECURSIVE_SEARCH_URL(){
UrlBackTmps=`cat $DownListTmpFile`
[[ "$UrlBackTmps" == "" ]] && echo "no more page for search" && exit 1
for j in $UrlBackTmps ;do
if [[ "${j##*\/}" != "" ]] ;then
echo "$j" >> $DownListFile
else
UrlBack="$j"
URL_LIST
fi
UrlTmps=`grep -vE "$j$" $DownListTmpFile`
echo "$UrlTmps" > $DownListTmpFile
RECURSIVE_SEARCH_URL
done
}
DOWNLOAD_FILE(){
DownList=`grep -E "$DownFileType" $DownListFile`
for k in $DownList ;do
FilePath=/tmp/${k#*\/\/}
[ ! -d `dirname $FilePath` ] && mkdir -p `dirname $FilePath`
[ ! -f $FilePath ] && cd `dirname $FilePath` && curl -O $k
done
}
URL_LIST $Urls
RECURSIVE_SEARCH_URL
相关内容
- mysql源码安装脚本分享_linux shell_
- 从apnic提取ip信息脚本分享_linux shell_
- 实现批量linux格式化硬盘和挂载硬盘脚本分享_linux shell_
- 自动生成linux网卡配置脚本分享_linux shell_
- Linux Shell脚本编程的注意事项_linux shell_
- Shell字符串截取的详细方法_linux shell_
- csh,tcsh,bash,sh等shell的区别_linux shell_
- shell脚本学习指南[六](Arnold Robbins & Nelson H.F. Beebe著)_linux shell_
- shell脚本学习指南[五](Arnold Robbins & Nelson H.F. Beebe著)_linux shell_
- shell脚本学习指南[四](Arnold Robbins & Nelson H.F. Beebe著)_linux shell_
 
                                
                                                         
                                
                                                         
                                
                                                         
 
    