调用脚本$();
if语句:
if[ -d ];then
xxx
else
xxx
fi
case语句:
case xxx in
xx)
xxx
;;
esac
while语句
while((xx))
do
xxx
done
demo:
#!/bin/bash
a=$(uname -r)
echo $a
function test_if
{
if [ -d /root ];then
result=""ok""
printf "ok
"
else
printf "error
"
result=error
fi
}
function test_if_ret
{
printf "%s
" $1
printf "%d
" 0xff
}
function test_case
{
case $1 in
"ok")
printf "ok in case
"
;;
"error")
printf "error in case
"
;;
esac
}
function test_for
{
i=0
while((i<25))
do
echo i=$((i++))
done
}
test_if
ret_if="data"
ret_if=$(test_if_ret $result)
echo $result