- ${var} 和 $var的区别
http://stackoverflow.com/questions/8748831/when-do-we-need-curly-braces-in-variables-using-bash
正常情况下都可以,特殊情况下需要用花括号来区分变量名和其他的字符
- “==”和 “=” 的区别
http://stackoverflow.com/questions/2600281/what-is-the-difference-between-operator-and-in-bash
正常情况下都可以使用,最好使用 “==”
- [] 、 [[]] 、 test 、 ((number compare only)) 都可以用来判断条件
- set / setenv / export /declare 的区别
export (in ksh/sh):exported var is accessible by all the shells or processes invoked by the original shell (an environment value)
set (in csh): set a local variable
setenv (in csh): set an environment variable
http://www.theunixschool.com/2010/04/what-is-difference-between-export-set.html
declare is used to declare variables and give them attribute
- boolean expressions
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
[ -a File ]
[ -d dir ]
[ -z String ]
[ -n String ]
[ Integer1 OP Interger2 ] "OP" is one of -eq, -ne, -lt, -le, -gt or -ge
test exit status:
[ $? -eq 0 ]
Regular expressions may also be used in comparisons:
if [[ "$gender" == f* ]]
- shell expansion
http://ss64.com/bash/syntax-expand.html
- Arithmatic Operation
http://www.tldp.org/LDP/abs/html/arithexp.html
z=$((z+3))
let z=z+3