批量下载资源循环脚本
#!/bin/bashTHREAD_COUNT=10
DOWNLOAD_DIR="/path/to/download/directory"
URL="http://www.baidu.com/123.zip"# 替换为你实际要下载的URL
LOOP_COUNT=99
download() {
local url=$1
local output_dir=$DOWNLOAD_DIR
local output_file=$(basename "$url")
local output_path="$output_dir/$output_file"
# 检查文件是否已存在
if [ -f "$output_path" ]; then
echo "文件已存在: $output_path"
rm "$output_path"# 删除已存在的文件
fi
# 下载文件
curl -# "$url" -o "$output_path"
echo "下载完成: $output_path"
}
main() {
local count=0
while [ $count -lt $LOOP_COUNT ]; do
download "$URL"# 下载单个URL
count=$((count+1))
echo "第$count次循环完成!"
done
echo "所有下载任务完成!"
}
if [ "$(basename "$0")" = "download.sh" ]; then
main "$@"
fi
页:
[1]