shell和其它编程语言一样,支持多种运算符,包括:算数运算符、关系运算符、布尔运算符、字符串运算符、文件测试运算符;
原生bash不支持简单地数学运算,可通过awk、expr命令实现;
如下图:通过expr命令实现两个数相加(注意使用的是反引号`,不是单引号');表达式和运算符之间要有空格,如2+2是不对的,必须写成2 + 2;
注意:乘号(*)前必须加反斜杠()才能实现乘法运算;
if...then...fi是条件语句;
相等 equal;不相等 not equal;大于 greater than;小于 less than;大于等于 greater than or equal to ;小于等于 less than or equal to ;
:> 文件名;清空文件内容;
文件测试运算符;用于检测Unix文件的各种属性;