脚本里犯了错 --
[oracle@simpleit shell]$ value=1
[oracle@simpleit shell]$ value = 1
-bash: value: command not found
[oracle@simpleit shell]$ value = 3
-bash: value: command not found
[oracle@simpleit shell]$ echo value
value
[oracle@simpleit shell]$ echo "value"
value
[oracle@simpleit shell]$ echo $value
1
[oracle@simpleit shell]$ echo '$value'
$value
[oracle@simpleit shell]$ echo "$value"
1
[oracle@simpleit shell]$
shell脚本中给变量赋值 = 两边不能有空格。
[oracle@simpleit shell]$ value=4
[oracle@simpleit shell]$ [$value -gt 2]
-bash: [4: command not found
[oracle@simpleit shell]$ [ $value -gt 2 ]
[oracle@simpleit shell]$ echo $?
0
[ ]多数用于比较判断,注意[ ]中"["后要有一空格,"]"前也要有一空格 。