Shell编程之变量

Shell编程之变量_第1张图片
overview.png

位置环境变量

num1=$1
num2=$2
sum=$(($num1+$num2))
echo $sum

预定义变量

echo "para is : $*"
echo "para is : $@"
echo "para num: $#"
for i in "$*"
        do
                echo "The parameters are: $i"
        done


for i in "$@"
        do
                echo "The parameters are: $i"
        done
echo "Current : $$"

find / -name hello.sh &
echo "background : $!"
*后台进程号$!未实现

read语句

read -p "please input your name: " -t 3 name
echo $name

read -p "please input your password: " -s passwd
echo -e "\n"
echo $passwd

read -p "please input your sex [M/F]: " -n 1 sex
echo -e "\n"
echo $sex

你可能感兴趣的:(Shell编程之变量)