#!/bin/bash
:<<!
echo "shell 传参测试";
echo "第一个参数是 $0";
echo "第二个参数是 $1";
echo "第三个参数是 $2";
s1=${1:-mmiao}
echo "第三个参数是 $s1";
!
#echo "miaoman"
echo "---0---test for loop array"
a2=(1 5 8 9 10)
length=${#a2[@]}
echo "array len is $length"
echo "array : ${a2[0]} ${a2[1]} ${a2[2]} ${a2[3]} ${a2[4]}"
for var in 0 1 2 3 4
do
echo " var=${a2[var]} "
done
echo "---1---test case "
case $1 in
1)
echo "1---"
;;
2)
echo "2---"
;;
*)
echo "unknown -----"
;;
esac
echo "---2---test local var func return value"
temp=2
echo "temp = $temp"
function return_test()
{
local temp=3
echo "local temp = $temp"
local temp1=4
echo "local temp1 = $temp1"
return $1
}
return_test 0
echo $?
return_test 1
echo $?
echo "temp = $temp"
echo "local temp1 = $temp1"
echo "---3---test file found "
a=mmiao
if [ ! -f ${a} ]
then
echo "not found"
else
echo "found"
fi
echo "---4---test dirname word bit "
echo "$(dirname "$0")"
echo "$(getconf WORD_BIT)"
echo "$(getconf LONG_BIT)"
echo "---5---test -a"