上次写了shell脚本的注释,没想到那么多人的须要,也存在很多不足。此次作个补充吧。前端
单行注释:git
单行注释就比较简单了,直接在行最前端加上符号 # 便可。具体用法以下所示:shell
# this is comment test echo "this is comment test"
运行结果:bash
➜ comment git:(master) ✗ sh comment.sh this is comment test
多行注释:this
多行注释有不少方法,这里就列举几个经常使用的spa
1 eof截止符code
eof截止符不但能够用做后续输入命令,还能够用做注释,经常使用用法:开始注释部分:输入::<<eof 结束部分:eofblog
具体示例以下所示:it
1 # echo is test 2 echo "test" 3 echo "test" 4 echo "test" 5 echo "test" 6 echo "test" 7 :<<eof 8 echo "comment" 9 echo "comment" 10 echo "comment" 11 echo "comment" 12 echo "comment" 13 echo "comment" 14 eof
运行结果:ast
➜ comment git:(master) ✗ bash comment.sh
test
test
test
test
test
2 感叹号
!号通常做为嵌入内容部分,能够用做注释,经常使用用法:开始注释部分:输入::<<! 结束部分:!
具体示例以下所示:
1 # echo is test 2 echo "test" 3 echo "test" 4 echo "test" 5 echo "test" 6 echo "test" 7 :<<! 8 echo "comment" 9 echo "comment" 10 echo "comment" 11 echo "comment" 12 echo "comment" 13 echo "comment" 14 !
运行结果:
➜ comment git:(master) ✗ bash comment.sh
test
test
test
test
test
3 逗号
逗号通常做区份内容,也能够用做注释,经常使用用法:开始注释部分:输入:: ' 结束部分:' (注意,逗号和冒号之间要加空格)
具体示例以下所示:
# echo is test echo "test" echo "test" echo "test" echo "test" echo "test" : ' echo "comment" echo "comment" echo "comment" echo "comment" echo "comment" echo "comment" '
运行结果:
➜ comment git:(master) ✗ bash comment.sh
test
test
test
test
test
自我感受,此次写的比较清晰了,但愿对你有用。