shell循环无法停止

sh/bash/dash/ksh/zsh等Shell脚本
回复
zjfcctv
帖子: 18
注册时间: 2009-03-29 18:15

shell循环无法停止

#1

帖子 zjfcctv » 2010-06-15 15:18

代码: 全选

#!/bin/bash
num=10
url=""
until  $num > 16
do
    url="http://home.arcor.de/pangj/squid/chap${num}.html"
    wget $url
    $((++num))
done
一个抓网页的脚本。
为什么这个脚本中的循环无法停止?请教大家了!
yangyongsheng
帖子: 2
注册时间: 2010-03-14 16:31

Re: shell循环无法停止

#2

帖子 yangyongsheng » 2010-06-15 16:25

#!/bin/bash
num=10
url=""
until [ "$num" -gt "16" ];do
url="http://home.arcor.de/pangj/squid/chap${num}.html"
wget $url
num=`expr $num + 1`
done
aerofox
帖子: 1453
注册时间: 2008-05-24 8:30

Re: shell循环无法停止

#3

帖子 aerofox » 2010-06-16 7:02

代码: 全选

#!/bin/bash
num=10
until  (( num > 16))
do
    url="http://home.arcor.de/pangj/squid/chap${num}.html"
    wget $url
    ((++num))
done

代码: 全选

wget http://home.arcor.de/pangj/squid/chap{10..16}.html

代码: 全选

for (( i=10; i<=16; i++)); do
    wget http://home.arcor.de/pangj/squid/chap$i.html
done
zjfcctv
帖子: 18
注册时间: 2009-03-29 18:15

Re: shell循环无法停止

#4

帖子 zjfcctv » 2010-06-16 15:51

谢谢,LS的几位,看来shell还是很灵活的。 :em11
tusooa
帖子: 6548
注册时间: 2008-10-31 22:12
系统: 践兔
联系:

Re: shell循环无法停止

#5

帖子 tusooa » 2010-07-01 21:09

代码: 全选

until  $num > 16
等你有$num(貌似是$num=10,11,...n中任意一个)这个命令之后就行了

代码: 全选

] ls -ld //
回复