多行命令中的批处理注释 [英] Batch Comment in Multi-Line Command

查看:132
本文介绍了多行命令中的批处理注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在批处理文件命令中添加注释.具体来说,我有一个长的 SED 命令,如下所示:

I am wondering if it is possible to have a comment within a batch file command. Specifically, I have a long SED command like the following:

@SED -r -e "s/.../.../"^
    -e "s/.../.../"^
    -e "s/.../.../"^
    fileName >outFileName

我想在每个"-e"选项中添加一个注释,如以下示例所示:

I would like to add a comment to each of the "-e" options, as indicated in the following examples:

:: 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

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

Is there any way to accomplish this?

推荐答案

尝试一下.我没有sed,所以我只是用echo进行了测试.

Give this a try. I don't have sed so I just tested with 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 . . .

这篇关于多行命令中的批处理注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆