linux shell用法(3)-- shell 格式总结
来源:互联网 发布:spss怎么输入大量数据 编辑:程序博客网 时间:2024/06/06 13:11
shell 格式总结
1.变量赋值时等号两边不能有空格
错误写法:
BUILD = user运行结果:编译错误,请查看程序高亮行!/usercode/file.sh: line 1: BUILD: command not found
正确写法:
BUILD=user
2.变量值中含有空格时,需要加上引号。
错误写法:
BUILD=wei cai hui运行结果:编译错误/usercode/file.sh: line 1: cai: command not found
正确写法:
BUILD="wei cai hui"echo $B运行结果:wei cai hui
3.推荐给所有变量加上花括号
4.所有字符 与逻辑运算符直接用“空格”分开,不能连到一起。
=等于 应用于:整型或字符串比较 如果在[] 中,只能是字符串!=不等于 应用于:整型或字符串比较 如果在[] 中,只能是字符串<小于 应用于:整型比较 在[] 中,不能使用 表示字符串>大于 应用于:整型比较 在[] 中,不能使用 表示字符串
-f常用!侦测『档案』是否存在 eg: if [ -f filename ]-d常用!侦测『目录』是否存在
5.在[] 表达式中,常见的>,<需要加转义字符,表示字符串大小比较,以acill码 位置作为比较。 不直接支持<>运算符,还有逻辑运算符|| && 它需要用-a[and] –o[or]表示
6.[[]] 运算符只是[]运算符的扩充。能够支持<,>符号运算不需要转义符,它还是以字符串比较大小。里面支持逻辑运算符:|| &&
0 0
- linux shell用法(3)-- shell 格式总结
- [Shell]: Linux命令find命令用法总结
- linux shell find 常用用法总结
- linux:shell脚本格式
- Linux Shell 日期格式
- shell date 用法总结
- shell awk 用法总结
- shell awk 用法总结
- shell用法总结
- Linux笔记--shell总结(3)
- linux shell awk用法
- linux shell 简单用法
- linux shell ${}简单用法
- linux shell ${ }的用法
- linux shell ${ }的用法
- linux shell test用法
- linux shell date用法
- linux shell ${}简单用法
- Gradle Plugin Samples (一)
- Linux下实现编写汇编程序
- Spiral Matrix
- Ubuntu下安装GCC编译器
- [LeetCode] Palindrome Linked List
- linux shell用法(3)-- shell 格式总结
- Gradle Plugin Samples 之 Gradle Hello World (二)
- Gradle Plugin Samples 之 Gradle Hello World (二)
- cocos2dx中RichText富文本的换行问题
- 图的连通性判断
- 最小生成树之 prim & kruskal
- 判断图的连通分量
- LeetCode 082 Remove Duplicates from Sorted List II
- Spiral Matrix II