我想知道是否可以在批处理文件命令中发表评论。具体来说,我有一个很长的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
有没有办法实现这个目标?
答案 0 :(得分:5)
试一试。我没有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 . . .