当前位置:首页 >> 脚本专栏

Shell脚本之无限循环的两种方法

for 实现:
复制代码 代码如下:
#!/bin/bash
set i=0
set j=0
for((i=0;i<10;))
do
        let "j=j+1"
        echo "-------------j is $j -------------------"
done

while实现:
复制代码 代码如下:
#!/bin/bash
set j=2
while true
do
        let "j=j+1"
        echo "----------j is $j--------------"
done