bat指令碼注釋多行 Shell中實現多行注釋

2021-10-13 20:29:32 字數 1552 閱讀 2709

shell中利用here documents實現多行注釋

#開頭的行就是注釋行,會被直譯器忽略。

shell中沒有多行注釋,只能每一行加乙個#號。

但是我們可以通過其他方式來實現多行注釋的效果。

下面我們就利用here documents實現多行注釋。

關於here documents請參考:

**linux中的標準重定向輸入和here document

格式:**eof

:是個空命令,返回狀態為0。

案例:#!/bin/bash

#利用here documents使用多行注釋

執行效果

注釋*****=裡面的內容

#!/bin/bash

#利用here documents使用多行注釋

#auth:odysee

echo "odysee - manian"

:<

echo "********************=="

echo "this is my odysee"

echo "this is my illusion"

echo "i'm lost in a dream of you and me"

echo "......"

echo "********************=="

eof

執行指令碼

測試完成。

感謝支援。

shell 中的單行注釋和多行注釋

1.單行注釋 眾所周知,比如想要注釋 echo ni echo ni 2.多行注釋 法一 語句1語句2 語句3語句4 例如 linux101 home wsj sh dian nini nini nini linux101 home wsj more dian bin ksh echo ni ech...

shell 多行注釋 2

由於shell不支援直接多行注釋,總結了以下shell注釋多行的變通方法 一 通過here documents和 實現 1 最簡單方法 注釋內容 block 把輸入重定義到前面的命令,但是 是空命令,所以就相當於注釋了。如果注釋中有反引號的命令就會報錯。反引號部分沒被注釋掉,例如ab ls l ab...

shell 多行注釋詳解

在我們寫 shell 指令碼的時候,特別在除錯的時候經常需要注釋多行命令,但在每一行前輸入 顯得有些麻煩。基於 shell 命令的靈活性,我們可以使用下面的方法 方法一 這是比較穩妥的作法 可以採用here document特性,實現多行注釋,比如 comment comment舉例如下 bin b...