Linux命令之for.docxVIP

  • 4
  • 0
  • 约1.51千字
  • 约 3页
  • 2017-05-28 发布于河南
  • 举报
Linux命令之for

Linux命令之forbash shell提供了for命令,用于创建通过一系列值重复的循环。每次重复使用系列中的一个值执行一个定义的命令集。for命令基本格式为:for var in listdo?? commandsdone1.读取列表中的值#!/bin/bash#basic for commandfor test in a b c d e fdo? echo The next state is $testdone每次for命令通过提供的值列表进行矢代时,它将列表中想下个值赋值给变量[root@localhost ~]# ./test1.sh?The next state is aThe next state is bThe next state is cThe next state is dThe next state is eThe next state is f2.读取列表中的复杂值#!/bin/bashfor test in i don\t?knowdo?echo Word:$testdone注意:分号()这里需要加斜杠(\)进行转义[root@localhost ~]# ./test2.sh?Word:iWord:dontWord:know3.从变量读取列表#!/bin/bashlist=a b c d for state in $list? doecho Have y

文档评论(0)

1亿VIP精品文档

相关文档