摘要: 条件语句 1 #!/bin/bash 2 3 read -p "input your name:" name 4 #第一种判断 5 if [ "$name" == "Mike" ]; then #注意这里用 [... ]比较两个字符串时,变量 $name 加引号,并且 "==" 两边有空格;"[... 阅读全文
posted @ 2015-01-10 11:26 502280728 阅读(281) 评论(0) 推荐(0) 编辑
摘要: shell scriptshell script 是利用shell功能写的一个“程序”,可以用来方便管理主机shell script 编写的注意事项:1.命令的执行时从上往下,从左往右;2.命令、参数间的多个空白会被忽略3.如果读取到Enter符号(CR),就尝试开始执行该行(或该串)命令4.如果一... 阅读全文
posted @ 2015-01-10 10:52 502280728 阅读(240) 评论(0) 推荐(0) 编辑
摘要: test判断式看下面:1 test -e /opt/a.txt && echo "exist" || echo "not exist"判断 /opt/a.txt 存不存在,存在输出 exist ,否则输出 not existtest还有很多用法:关于某个文件名的”文件类型“判断,如 test -... 阅读全文
posted @ 2015-01-10 10:52 502280728 阅读(604) 评论(0) 推荐(0) 编辑