如何在cmd批处理中的文本中使用换行符?

Tom*_*ski 11 svn batch-file

我想要做

svn commit -m "<message>"
Run Code Online (Sandbox Code Playgroud)

但是消息应该有两行:

Commit by: firstuser
Bug track: 9283
Run Code Online (Sandbox Code Playgroud)

如何在邮件中添加换行符?我尝试过SHIFT + ENTER,CTRL + T但它不起作用.我使用MS cmd命令行.

aph*_*ria 12

如何使用-F参数从文件中获取日志消息?

然后,你可以这样做(未经测试):

ECHO Commit by: firstuser>SvnLog.txt
ECHO Bug track: 9283>>SvnLog.txt

SVN COMMIT -F SvnLog.txt
Run Code Online (Sandbox Code Playgroud)


Cla*_*ren 12

我在Serverfault找到了答案:

svn ci -m $'This is the first line\nThis is the second line'
Run Code Online (Sandbox Code Playgroud)

显然这是一个shell问题.

  • 这不适用于Windows中的cmd.exe,因为该解决方案基于linux shell而不是svn客户端.但是你引用的主题让我思考并找到了另一种选择. (4认同)

Pio*_*iak 7

我有同样的问题,虽然Claes Mogren的答案不适用于cmd.exe,但它让我觉得如果Windows上有一个可以做到这一点的shell.
当然还有...... PowerShell.

使用PowerShell shell,您可以使用以下命令实现此目的:

svn ci -m "reference to Ninject fixed`nsome ignores added"
Run Code Online (Sandbox Code Playgroud)

注意消息中backqoute和n的组合

`n
Run Code Online (Sandbox Code Playgroud)


jeb*_*jeb 6

要在svn消息中创建换行符,最好的方法是使用额外消息文件的aphoria.

但它也可以用 -m

使用批处理文件进行采样

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set lf=^


rem ** Two empty lines are neccessary for creating the Linefeed
svn commit -m "A!lf!Message!lf!with!LF!newline"
Run Code Online (Sandbox Code Playgroud)

您也可以在命令行中使用它

svn commit -m ^"This is a^
MORE?
MORE?my newline"
Run Code Online (Sandbox Code Playgroud)


mou*_*sio 5

您可以按如下方式定义换行符:

set newline=^& echo.
Run Code Online (Sandbox Code Playgroud)

然后,您可以在其他语句中使用换行符,如下所示:(无引号)

echo This is the first line%newline%This is the second line
echo "This is the first line"%newline%"This is the second line"
Run Code Online (Sandbox Code Playgroud)

或者有一个额外的插入符号,像这样:

set text=This is the first line^%newline%This is the second line
Run Code Online (Sandbox Code Playgroud)

也许您可以使用它,但请注意与引号的组合!


Luk*_*ius 5

只需svn ci -m "old line按下Enter然后键入下一行new line"

例

这比使用文件容易得多.