我正在嘗試使shell腳本讀取下載URL列表以查找它們是否仍處於活動狀態。我不確定我當前的腳本有什麼問題,(我是新手),任何指針都會有很大的幫助!使用Wget的Shell腳本 - 如果其他嵌套在循環中
用戶@ PC:〜/測試#貓sites.list
http://www.google.com/images/srpr/logo3w.png
http://www.google.com/doesnt.exist
notasite
腳本:
#!/bin/bash
for i in `cat sites.list`
do
wget --spider $i -b
if grep --quiet "200 OK" wget-log; then
echo $i >> ok.txt
else
echo $i >> notok.txt
fi
rm wget-log
done
不變,那麼腳本輸出一切notok.txt - (第一款谷歌網站應去ok.txt)。 但是,如果我運行:
wget --spider http://www.google.com/images/srpr/logo3w.png -b
然後執行:
grep "200 OK" wget-log
這裏grep沒有任何問題的字符串。我用語法做了什麼noob錯誤?感謝m8s!
好趕! +1 – Graham
確實。我也是+1。 :) – ghoti
作品!謝謝! –