vieyahn2017 / shellv

shell command test and study
4 stars 1 forks source link

11.6 Linux shell 用for循环100次的方法 #73

Open vieyahn2017 opened 3 years ago

vieyahn2017 commented 3 years ago

Linux shell 用for循环100次的方法 https://blog.csdn.net/wr339988/article/details/70768499

vieyahn2017 commented 3 years ago

C语言风格

for ((i=1; i<=100; i++))
do
    echo $i
done
vieyahn2017 commented 3 years ago

Python风格(in的使用)

for i in {1..100}
do
    echo $i
done
vieyahn2017 commented 3 years ago

Seq的使用 注意代码中不是单引号。

for i `seq 1 100`
do
    echo $i
done
vieyahn2017 commented 3 years ago

while

i=0
times=100
while [ $i -le $times ]
do
    let 'i++'
    echo $i
done
vieyahn2017 commented 1 year ago

https://github.com/gyliu513/roadmap/blob/master/linux/shell/for.md