这是我的代码。
file_name="all_parts"
find parts/ -type f > ${file_name}
while read part
do
echo processing ${part}
cat ${part} | parallel -j 100 'wget {} -o logs/wget{%}.log --no-check-certificate -t 2 -w 1 --timeout 20 -O - | aws s3 cp - s3://download/bamboo/extra/{/} && echo {#} >count.txt'
echo ${part} ok
rm -rf ${part}
done < ${file_name}
这是我的环境。
(py38) $ head all_parts
parts/segment03
parts/segment04
parts/segment05
parts/segment06
parts/segment07
parts/segment08
parts/segment09
parts/segment10
parts/segment11
parts/segment12
(py38) $ head parts/segment03
https://live.staticflickr.com/7024/6592983699_97d938811c_c.jpg
https://live.staticflickr.com/2749/4259562954_90c98d6969_c.jpg
https://live.staticflickr.com/3054/2559722683_b529ba8040_c.jpg
https://live.staticflickr.com/7407/9952335963_293b119412_c.jpg
https://live.staticflickr.com/1116/617893639_6ab5d13bc8_c.jpg
https://live.staticflickr.com/5346/8755170316_01ce687983_c.jpg
https://live.staticflickr.com/7122/27460712882_bfc7934ce5_c.jpg
https://live.staticflickr.com/6238/6376754433_58c029f20d_c.jpg
https://live.staticflickr.com/5708/31021117812_d58d1ee36b_c.jpg
https://live.staticflickr.com/4029/4229643400_7e23fe8c65_c.jpg
Sach 段文件有 10,000 行
我的问题是echo ${part} ok
永远不会打印,并且 shell 在第一个段文件处挂起,不会逐个处理段文件。
更新:当我输入Ctrl+时C,bash 将继续处理下一段。
更新2:现在我将段文件拆分为每个文件 1000 行,然后我的 shell 脚本就可以按预期顺利运行。