Jef*_*f G 1 comments sed batch-file multiline
我想知道是否可以在批处理文件命令中发表评论.具体来说,我有一个很长的SED命令,如下所示:
@SED -r -e "s/.../.../"^
-e "s/.../.../"^
-e "s/.../.../"^
fileName >outFileName
Run Code Online (Sandbox Code Playgroud)
我想在每个"-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
Run Code Online (Sandbox Code Playgroud)
有没有办法实现这个目标?
试一试.我没有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
Run Code Online (Sandbox Code Playgroud)
产量
SED -r -e "s/.../.../" -e "s/.../.../" -e "s/.../.../"
SED -r -e "s/.../.../" -e "s/.../.../" -e "s/.../.../"
Press any key to continue . . .
Run Code Online (Sandbox Code Playgroud)