赋值
x="abc" # = 前后不能有空格
条件判断
if cond; then # some code elif cond2; then # some code fi if [ "$a" == "x" ]; then # 空格不能少 if oscommand ; then # oscommand 成功,返回0, oscommand 也返回true, 否则返回false example: if echo "abc" | grep -q ab; then
function
function f() { echo "f" $1 # $1 为第一个参数 } f "par1" # 调用函数f, 注意没有括号 function g() { eval "$1='abcdef '" }outstr=''g outstrecho $outstr # $outstr == "abcdef" now