2013-07-07 29 views
-1

您好我有多个文件,例如 01.pdf 02.pdf 等使用curl下载与填充零

在bash脚本我创建了一个for循环,用卷曲的文件,但是它会尝试下载 1.pdf 2.pdf etc

有没有解决方法?

回答

2

您可以填充文件名中使用printf

urlbase='http://myhost.com/path/files' 
for i in {1..10}; do 
    fname=$(printf "%02d.pdf\n" $i) 
    curl -o $fname "$urlbase/$fname" 
done 
+0

我明白,但我会如何实现与curl命令? – user2402616

+1

更新了答案 – perreal

+0

工作感谢!! – user2402616