多行命令中的批注
Batch Comment in Multi-Line Command
我想知道是否可以在批处理文件命令中添加注释。具体来说,我有一个很长的 SED
命令,如下所示:
@SED -r -e "s/.../.../"^
-e "s/.../.../"^
-e "s/.../.../"^
fileName >outFileName
我想为每个“-e”选项添加注释,如以下示例所示:
:: Option #1: At the end of the line
@SED -r -e "s/.../.../"^ // First comment
-e "s/.../.../"^ // Second comment
-e "s/.../.../"^ // Third comment
fileName >outFileName
:: Option #2: Between lines
@SED -r
@REM First comment
-e "s/.../.../"^
@REM Second comment
-e "s/.../.../"^
@REM Third comment
-e "s/.../.../"^
fileName >outFileName
有什么办法可以做到吗?
试一试。我没有 sed 所以我只是用 echo 测试。
@echo off
:: Option #1: At the end of the line
echo SED -r -e "s/.../.../" %= First comment =%^
-e "s/.../.../" %= second comment =%^
-e "s/.../.../" %= third comment =%
:: Option #2: Between lines
echo SED -r^
%= First comment =%^
-e "s/.../.../"^
%= second comment =%^
-e "s/.../.../"^
%= third comment =%^
-e "s/.../.../"
pause
输出
SED -r -e "s/.../.../" -e "s/.../.../" -e "s/.../.../"
SED -r -e "s/.../.../" -e "s/.../.../" -e "s/.../.../"
Press any key to continue . . .
我想知道是否可以在批处理文件命令中添加注释。具体来说,我有一个很长的 SED
命令,如下所示:
@SED -r -e "s/.../.../"^
-e "s/.../.../"^
-e "s/.../.../"^
fileName >outFileName
我想为每个“-e”选项添加注释,如以下示例所示:
:: Option #1: At the end of the line
@SED -r -e "s/.../.../"^ // First comment
-e "s/.../.../"^ // Second comment
-e "s/.../.../"^ // Third comment
fileName >outFileName
:: Option #2: Between lines
@SED -r
@REM First comment
-e "s/.../.../"^
@REM Second comment
-e "s/.../.../"^
@REM Third comment
-e "s/.../.../"^
fileName >outFileName
有什么办法可以做到吗?
试一试。我没有 sed 所以我只是用 echo 测试。
@echo off
:: Option #1: At the end of the line
echo SED -r -e "s/.../.../" %= First comment =%^
-e "s/.../.../" %= second comment =%^
-e "s/.../.../" %= third comment =%
:: Option #2: Between lines
echo SED -r^
%= First comment =%^
-e "s/.../.../"^
%= second comment =%^
-e "s/.../.../"^
%= third comment =%^
-e "s/.../.../"
pause
输出
SED -r -e "s/.../.../" -e "s/.../.../" -e "s/.../.../"
SED -r -e "s/.../.../" -e "s/.../.../" -e "s/.../.../"
Press any key to continue . . .