
我有一個網域檔案(~9000 個網址)。我試圖確定對所有 url 成功執行捲曲請求所需的時間。
#!/bin/bash
#read lines from file.
while read -r line || [[ -n "$line" ]]; do
#Start execution time.
start=`date +%s.%N`
curl -k -L $line
if (("$?" != "7")) || (("$?" != "6")) ||(("$?" != "35")) ; then
#If curl request is not one of these [error codes][1] then end execution time
end=`date +%s.%N`
fi
runtime=$( echo "$end - $start" | bc -l ) >> throughput.txt
#Can do an average on the file later.
done < urls.txt
由於某種原因,循環在讀取第一個 url 後停止。有人可以幫我正確地運行腳本嗎?