在 Shell 中标记语句的结束有两种方式:分号和换行。

例如下面的 Shell 脚本:

a=10
if [ $a = 10 ]; then 
  echo "the value of a is 10"
fi

也可以写成:

a=10
if [ $a = 10 ]
then 
  echo "the value of a is 10"
fi

即上面将 if 表达式后面的分号换成换行符了。但是不推荐这种写法,因为这样不利于阅读。因为最好的阅读方式就是 if 和 fi 对齐,中间是执行的语句,就像上面一开始的例子一样。

https://www.cnblogs.com/chanshuyi/p/quick_start_of_shell_05_sentence_end_syntax.html

相关文章:

  • 2022-02-21
  • 2022-01-21
  • 2021-12-03
  • 2021-12-04
  • 2021-10-17
  • 2022-12-23
  • 2021-11-15
  • 2022-01-15
猜你喜欢
  • 2021-07-12
  • 2022-12-23
  • 2021-09-26
  • 2021-12-15
  • 2022-12-23
  • 2021-11-28
相关资源
相似解决方案