1 echo命令基本情况: echo显示普通字符:echo "i am studying shell"(有木有引号都可以) 支持转义字符:echo "\"hello\""(结果是”hello“). 显示变量:echo "$name is my arguement", 注意read name 是一个特殊用法,相当于raw_input(), 当脚本文件中内容如下时候: #!/bin/bash read name #表示从脚本外获得…
1for命令 for命令的基本格式: for var in list do commands done 在list参数中,你需要提供迭代中要用到的一系列值. 1.1读取列表中的值 例子: $ vim test1 #!/bin/bash # testing the for variable after the looping for test in Alabama Alaska Arizona Arkansas California Colorado do echo "The next state…
1使用if-then语句 f-then语句有如下格式. if command then commands fi bash shell的if语句会运行if后面的那个命令.如果该命令的退出状态码是0(该命令成功运行),位于then部分的命令就会被执行.如果该命令的退出状态码是其他值, then部分的命令就不会被执行,bash shell会继续执行脚本中的下一个命令.fi语句用来表示if-then 语句到此结束. 举例: $ vim test1.sh #!/bin/bash # testing the…