服務(wù)器維護(hù)shell 腳本中的注釋詳解
2020-07-06 21:12 作者:admin
服務(wù)器維護(hù)小知識(shí) 單行注釋:
單行注釋就比較簡(jiǎn)單了,直接在行最前端加上符號(hào) # 即可。具體用法如下所示:
# this is comment test
echo "this is comment test"
運(yùn)行結(jié)果:
? comment git:(master) ? sh comment.sh
this is comment test
多行注釋:
多行注釋有很多方法,這里就列舉幾個(gè)常用的
服務(wù)器維護(hù)小知識(shí)1 eof截止符
eof截止符不但可以用作后續(xù)輸入命令,還可以用作注釋,常用用法:開始注釋部分:輸入::<<eof 結(jié)束部分:eof
具體示例如下所示:
# echo is test
echo "test"
echo "test"
echo "test"
echo "test"
echo "test"
:<<eof
echo "comment"
echo "comment"
echo "comment"
echo "comment"
echo "comment"
echo "comment"
eof
運(yùn)行結(jié)果:
? comment git:(master) ? bash comment.sh
test
test
test
test
test
服務(wù)器維護(hù)小知識(shí)2 感嘆號(hào)
?。√?hào)一般作為嵌入內(nèi)容部分,可以用作注釋,常用用法:開始注釋部分:輸入::<<! 結(jié)束部分:!
具體示例如下所示:
# 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"
!
運(yùn)行結(jié)果:
? comment git:(master) ? bash comment.sh
test
test
test
test
test
服務(wù)器維護(hù)小知識(shí)3 逗號(hào)
逗號(hào)一般作區(qū)分內(nèi)容,也可以用作注釋,常用用法:開始注釋部分:輸入:: ' 結(jié)束部分:' (注意,逗號(hào)和冒號(hào)之間要加空格)
具體示例如下所示:
# 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"
'
運(yùn)行結(jié)果:
? comment git:(master) ? bash comment.sh
test
test
test
test
test
IT運(yùn)維 我們選擇北京艾銻無(wú)限
以上文章由北京艾銻無(wú)限科技發(fā)展有限公司整理