代码之家  ›  专栏  ›  技术社区  ›  Jeff G

多行命令中的批处理注释

  •  1
  • Jeff G  · 技术社区  · 9 年前

    我想知道是否可以在批处理文件命令中添加注释。具体来说,我有一个 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
    

    有什么方法可以做到这一点吗?

    1 回复  |  直到 9 年前
        1
  •  5
  •   Squashman Stephan    9 年前

    试试这个。我没有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 . . .
    
    推荐文章