bash shell for循环1到100
2013-03-14 18:42 15787人阅读 评论(2) 收藏 举报
分类: bash shell(23)
版权声明:本文为博主原创文章,未经博主允许不得转载。
目录(?)[+]
前言
用bash shell写程序时,经常会用到for循环,特别是从1到100这种需求,这里记录几种shell中从1到100的循环方法
方法
类c语言
[html] view plain copy print?
for ((i=1; i<=100; i ++))
do
echo $i
done
in使用
[html] view plain copy print?
for i in {1..100}
do
echo $i
done
seq使用
作用
[html] view plain copy print?
seq - print a sequence of numbers
代码
[html] view plain copy print?
for i in seq 1 100
do
echo $i
done
后记
虽然这篇博客没什么技术含量,但是记录一下总是遗忘的shell语法,省得每次都去google,特别是现在翻墙google服务都不稳定!