文章目录
1.shell语法——条件测试
1.1 条件测试
1.2 条件测试
2.shell语法——分支语句
#! /bin/bash
if [ -d ceshi1 ]; then
echo "it is a dir"
elif [ -f ceshi1 ]; then
echo "it is a file"
else
printf "unknow\n"
fi
3.shell语法——case分支语句
#! /bin/bash
echo "输入 yes or no"
read BUF
case "$BUF" in
yes|Y|y|Yes)
echo "it is a yes.";;
[nN]?)
echo "it is a no.";;
*)
echo "other case";;
esac
return 0
4.shell语法——foreach循环
5.shell语法——while循环
6.shell语法——break和continue
7.位置参数和特殊变量
8.输入输出
8.1 echo
8.2 管道
8.3 tee
8.4 文件重定向
9. 函数
#! /bin/bash
foo()
{
echo $1
echo $2
echo $3
echo "function"
}
echo "-----strat-----"
foo $1 $2 $3
echo "-----end-------"