在Bash中,#用于评论以下内容。如何在Windows命令行上发表评论?
答案 0 :(得分:188)
您可以使用rem
作为备注,也可以使用更简写的版本::
,如果您稍微眯一眼并侧身看它,那么它看起来像#
: - )
我原本更喜欢::
变种,因为我是bash
- aholic,我仍然试图忘记BASIC的痛苦岁月。
不幸的是,有些情况::
填满了命令行处理器(例如复杂的if
或for
语句中),所以我现在通常使用rem
。< / p>
答案 1 :(得分:23)
使用REM命令生成注释,该命令是“备注”的缩写。
REM Comment here...
答案 2 :(得分:20)
有时,向命令行添加注释很方便。为此,您可以使用“&amp; REM misc评论文本”,或者,现在我知道它,“&amp; :: misc comment text”。例如:
REM SET Token="4C6F72656D20697073756D20646F6C6F" &REM This token is for localhost
SET Token="722073697420616D65742C20636F6E73" &REM This token is for production
这使得在进行探索,概念测试等时可以轻松跟踪多组值。这种方法之所以有效,是因为'&amp;'在同一行引入了一个新命令。
答案 3 :(得分:12)
这是“REM”。
示例:
REM This is a comment
答案 4 :(得分:7)
以“rem”开头的行(来自单词备注)是注释:
rem comment here
echo "hello"
答案 5 :(得分:0)
: this is one way to comment
REM is another way to comment.
结果:
:: this will also work
:; so will this
:! and this
答案 6 :(得分:0)
对于powershell,请使用#
:
PS C:\> echo foo # This is a comment
foo
答案 7 :(得分:0)
一个冒号后没有空格就足够了
不要在块的最后一行留下评论
最后,这是有效的:
if 1==1 (
:comment line 1
echo 1 equals 1
)