1:
定义变量时, =号的两边不可以留空格.
eg:
gender=femal------------right
gender =femal-----------wrong
gender= femal-----------wrong
2
条件测试语句 [ 符号的两边都要留空格.
eg:
if [ $gender = femal ]; then-------right.
echo "you are femal";
fi
if[ $gender...-----------------------wrong
if [$gender...----------------------wrong.
3
条件测试的内容,如果是字符串比较的话, 比较符号两边要留空格!
eg:
if [ $gender = femal ]; then-------right.
if [ $gender= femal ]; then--------wrong.
if [ $gender=femal ]; then---------wrong.
4
如果if 和 then写在同一行, 那么,注意, then的前面要跟上 ; 号.
如果 then 换行写, 那么也没问题.
eg:
if [ $gender = femal ]; then-------right.
if [ $gender = femal ]
then-------------------------------right.
if [ $gender = femal ] then-------wrong. then前面少了 ; 号.
提示出错信息:
syntax error near unexpected token then
同理,还有很多出错信息 比如
syntax error near unexpected token fi 等都是这样引起的.
5
if 后面一定要跟上 then. 同理
elif 后面一定要跟上 then.
不然提示出错信息:
syntax error near unexpected token else
1)if 语句后面需要跟着then,同时前面要有分号;
2) 空格非常重要,shell 会认为空格前的为一个命令,如果a=3 认为是赋值操作,如果写成a = 3,那么就会认为a为一个命令 this=`ls -l |grep '^-' | wc -l `
3) 操作符之间要用空格分开 ,如 test ! -d $1,其中的!和-d就要用空格分开
空格是命令解析中的重要分隔符
http://blog.csdn.net/qzwujiaying/article/details/6321068
分享到:
相关推荐
博客 https://gudianxiaoshuo.blog.csdn.net/article/detail VUE 组件示例
博客https://blog.csdn.net/weixin_49457347/article/details/1236所需文件
weUI 入门教程:http://blog.csdn.net/libin_1/article/details/50734266
来自博客http://blog.csdn.net/uq_jin/article/details/51484890的代码
busybox-1.32.0._tar__.bz2文件系统: https://blog.csdn.net/tan1666/article/details/123156383
https://blog.csdn.net/a6661314/article/details/124358796的实验文件
http://blog.csdn.net/qq282133/article/details/7616809
https://blog.csdn.net/zhang24360/article/details/83098575文章里面所介绍
接前两篇文章,[小学生python游戏编程3----拼图游戏-准备](https://blog.csdn.net/fqfq123456/article/details/127173684),[小学生python游戏编程4----拼图游戏今天]...,上次写到可以打乱图片,拼成游戏界面,今天...
KITTI数据集可视化教程,教程:https://blog.csdn.net/cg129054036/article/details/119516704
https://jiejie.blog.csdn.net/article/details/82743945
用于:https://laoshifu.blog.csdn.net/article/details/138191428 springboot多层文件夹创建,包含了多层文件夹结构。但是还没有带入代码。
详情看我的我的文章https://blog.csdn.net/wsxybz/article/details/128486717
安装步骤:https://blog.csdn.net/qq_53810245/article/details/123674836
文章链接:https://blog.csdn.net/Jeankyw/article/details/131890436?spm=1001.2014.3001.5502
原博地址:http://blog.csdn.net/u013806766/article/details/52981497
Keil5 MDK的软件安装步骤:https://blog.csdn.net/qq_53810245/article/details/123674836
https://blog.csdn.net/huangjhai/article/details/118854733
http://blog.csdn.net/y670340559/article/details/77637604 详见该链接
登录页面的图标 文章地址:https://blog.csdn.net/qq3892997/article/details/12