导读 | 关于 shell 中的单行注释和多行注释的问题,本文档介绍两种实用的方法。 |
1. 单行注释
众所周知 # , 比如想要注释 echo “Hello World”
[root@Jaking ~]# vim test.sh # echo "Hello World"
2. 多行注释:
法一:
: << ! 语句1 语句2 语句3 语句4 !
例如:
[root@Jaking ~]# bash test.sh Hello World Hello World Hello World Hello World Hello World Hello World [root@Jaking ~]# cat test.sh #!/bin/ksh echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" :<<! echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" !
法二:
: ' 语句1 语句2 语句3 语句4 '
例如:
[root@Jaking ~]# bash test.sh Hello World Hello World Hello World Hello World Hello World Hello World [root@Jaking ~]# cat test.sh #!/bin/ksh echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" : ' echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" echo "Hello World" '
总结
以上就是关于 shell 注释的方法介绍,选择其中一种来用即可。
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/123206.html