求多线程下载脚本
发表于 : 2017-08-28 18:47
最近使用you-get下载大量的优酷的视频。眼下需要多线程下载,这样才能利用带宽。
但是目前不太懂如何写多线程的下载脚本。我是使用shell来写的。
估计写的可能不对,
高手指点!!
#!/bin/bash
for ((a=1;a<100;a++))
do
for ((i=1;i<11;i++))
do
if [ $i == 1 ]
then
echo $i time
else
echo $i times
fi
echo the ${2*a-1} file of `cat link-down|wc -l` files in total
you-get `sed -n ${2*a-1}p link-down` &
echo the ${2*a} file of `cat link-down|wc -l` files in total
you-get `sed -n ${2*a}p link-down`
done
done
这个是双线程的,目前我只会写着一种,不知道有没有更好的写法,也没有实际测试过这个脚本能不能用。
谢谢指点!!
但是目前不太懂如何写多线程的下载脚本。我是使用shell来写的。
估计写的可能不对,
高手指点!!
#!/bin/bash
for ((a=1;a<100;a++))
do
for ((i=1;i<11;i++))
do
if [ $i == 1 ]
then
echo $i time
else
echo $i times
fi
echo the ${2*a-1} file of `cat link-down|wc -l` files in total
you-get `sed -n ${2*a-1}p link-down` &
echo the ${2*a} file of `cat link-down|wc -l` files in total
you-get `sed -n ${2*a}p link-down`
done
done
这个是双线程的,目前我只会写着一种,不知道有没有更好的写法,也没有实际测试过这个脚本能不能用。
谢谢指点!!