|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
小知识:如果说Ubuntu是现今最受桌面用户欢迎的Linux操作系统,那么CentOS就是最受公司、企业、IDC喜爱的Linux发行版了。
<divclass="detail"id="detail"style="line-height:1.3">
for轮回示例
for轮回语法:
1forVARIABLEin12345..N
2do
3command1
4command2
5commandN
6done
01#!/bin/bash
02
03foriin12345
04
05do
06
07echo"Welcome$itimes"
08
09done
10
bashversion3.0+版本
#!/bin/bash
foriin{1..5}
do
echo"Welcome$itimes"
done
bashversion4版本
#!/bin/bash
echo"Bashversion${BASH_VERSION}..."
foriin{0..10..2}
do
echo"Welcome$itimes"
done
含有“seq”敕令的语法示例
#!/bin/bash
foriin$(seq1220)
do
echo"Welcome$itimes"
done
for轮回的三个表达式
语法以下:
for((EXP1;EXP2;EXP3))
do
command1
command2
command3
done
示例以下:
#!/bin/bash
for((c=1;c<=5;c++))
do
echo"Welcome$ctimes..."
done
后果:
Welcome1times
Welcome2times
Welcome3times
Welcome4times
Welcome5times
for的无穷轮回
<divclass="cnblogs_Highlighter"><divclass="syntaxhighlighternogutter"id="highlighter_988302"style="background-image:none!important;position:relative!important;text-align:left!important;padding-bottom:1px!important;border-right-width:0px!important;background-color:rgb(255,255,255)!important;font-style:normal!important;margin:1em0px;padding-left:1px!important;outline-width:0px!important;width:705px;bottom:auto!important;padding-right:1px!important;font-family:Consolas,BitstreamVeraSansMono,CourierNew,Courier,monospace!important;float:none!important;border-top-width:0px!important;border-bottom-width:0px!important;height:auto!important;font-size:1em!important;vertical-align:baseline!important;border-left-width:0px!important;top:auto!important;right:auto!important;font-weight:normal!important;padding-top:1px!important;left:auto!important;background-origin:initial;background-clip:initial"><divclass="lines"style="background-image:none!important;position:static!important;text-align:left!important;padding-bottom:0px!important;border-right-width:0px!important;font-style:normal!important;margin:0px;padding-left:0px!important;outline-width:0px!important;width:auto!important;bottom:auto!important;padding-right:0px!important;font-family:Consolas,BitstreamVeraSansMono,CourierNew,Courier,monospace!important;float:none!important;border-top-width:0px!important;border-bottom-width:0px!important;height:auto!important;font-size:1em!important;vertical-align:baseline!important;border-left-width:0px!important;top:auto!important;right:auto!important;font-weight:normal!important;padding-top:0px!important;left:auto!important;background-origin:initial;background-clip:initial">#!/bin/bash |
|