- 论坛徽章:
- 0
|
我下載足球報的 shell script
lynx --dump $url | sed '/ShowSoccer\./!d;s/ *[0-9][0-9]*\. //' | uniq > $temp
利用 lynx --dump 取得 links , 那些 links 含有 ShowSoccer.就是我要下載的,
用 sed 的 regexp '/ShowSoccer\./' 指定, !d 是 sed 的「不要拆除」,相等
于 sed -n '/...../p' `;' 是sed 用來分隔命令,相等于 sed -e '.......' -e '.......' ,因為lynx --dump 在每個 links 加入了 一個以上的空格和數字,
用 sed 的 s 命令拆除, / *[0-9][0-9]*\. / 是一個表示式
也可寫成 / \{1,\}[0-9]\{1,\}\. /
表示一個或以上的空格緊隨一個或以上的數字加一點及一個空格
uniq 把相同的links 不要
k=$(<$temp)
是 bash 的寫法,等于 k=`cat $temp`,不過沒有呼叫 cat ,理論上
速度快些。
while read n ;do wget -P $mydir -c $n ; done < $temp
用 while read的方式使 Wget 從 $temp 讀入 links 下載並
存到指定的目錄。 |
|