SHELL学习笔记三
SHELL学习笔记三 SHELL学习笔记一 SHELL学习笔记二 SHELL学习笔记三 for 命令 for var in list do commands done $ cat test1 #!/bin/bash # basic for command for test in Alabama Alaska Arizona Arkansas California Colorado do echo The next state is $test done $ ./test1 The next state is Alabama The next state is Alaska The next state is Arizona The next state is Arkansas The next state is California The next state is Colorado $ 读取列表中的复杂值 使用转义字符(反斜线)来将单引号转义; 使用双引号来定义用到单引号的值。 $ cat test2 #!/bin/bash # another example of how not to use the for command for test in I don\'t know if "this'll" work do echo "word:$test" done $ .