Shell编程基础(2)
2015-06-18 10:12
453 查看
test 测试条件 用于判断:整数,字符串,文件 test str1=str2 测试字符串是否相等 test str1!=str2 测试字符串是否不等 test -n str1 测试字符串是否不为空 test -z str1 测试字符串是否为空 test 1 -eq 2 测试整数是否相等 test 1 -ge 2 测试1是否>=2 test 1 -gt 2 测试1是否>2 test 1 -le 2 测试1是否<=2 test 1 -lt 2 测试1是否<2 test 1 -ne 2 测试整数是否不相等 test -d file 测试指定文件是否是目录 test -f file 测试指定文件是否是常规文件 test -x file 测试文件是否可执行 test -r file 测试文件是否可读 test -w file 测试文件是否可写 test -a file 测试文件是否存在 test -s file 测试文件大小是否非0 |
if分支循环语句 if test -d $1 then .... else ..... fi test -d $1可以简化写成 [ -d $1] 一个相对复杂的if结构 if 条件 then 命令 elif 条件 then 命令 else 命令 fi -a 逻辑与 -o 逻辑或 exit 0 直接退出脚本运行正确退出 exit 非0数字 退出,脚本运行中有错误退出 |
for ...... done 语句 for 变量 in 一堆变量 do 命令 done |
相关文章推荐
- Vim简明教程【CoolShell】
- Linux Shell Bash 精彩脚本示例
- shell脚本编程
- shell脚本实例
- msfvenom / ndisasm - disass shellcode
- 用shell比较2个文件的内容
- adb shell input 命令
- 使用xshell出现乱码
- 修改linux shell登陆欢迎信息
- shell 文本单词计数
- delphi Service里Shellexecute打开cmd返回ERROR_ACCESS_DENIED(权限不足)
- hadoop 创建用户及hdfs权限,hdfs操作等常用shell命令
- shell命令之split
- Shell 基础
- shell tr 命令
- shell 的cut 命令用法
- shell中if语句特殊参数
- shell与export命令
- win7 xshell登录虚拟机的centos
- #!/bin/bash(转)