#变量的运算
x=1
y=2
echo $(($x*$y)) #这里注意有两个()
#./xx.sh这是在bush子进程来执行
#source xx.sh 这是在父进程中执行
# ./执行后,在外面echo $x x是显示不存在的
# source x.sh x 在外面是存在的
#test 命令
test -e c && echo exist || echo not exist #检测c是否存在
test -x z && echo execute || echo unexe #测试一个文件是否能执行 ,-r 是否可读 -w可写
#!/bin/bash
read -p "please input your choose:" c
echo "your input is $c"
if [ "$c" == "yes" ]; then #这里强调一万次,[]里面最左边一片空格,最右边也是空格,之前老是错误,找不到原因
echo "your computer is conquered"
elif [ "$c" == "no" ]; then
echo "success"
else
echo "no match"
fi
循环:
read -p "please input your name :" name
while [ $name != "quking" ]
do
read -p "input again :" name
done
echo "you are good "
exit 0 #具体比较还要参考p381