DOS:多行字符串工作 [英] DOS: Working with multi-line strings

查看:258
本文介绍了DOS:多行字符串工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个绕过一个字符串线将其送至但它不工作了一个批处理文件。字符串的继续作为一个新的命令执行。

I'm trying to create a batch file which passes around a string with line feeds in it but its not working out. The continuation of the string is executed as a new command.

反正是有恩code换行或使这项工作?

Is there anyway to encode a line feed or make this work?

推荐答案

您可以创建一个插入符(要求使用一个空行)直接多行字符串。

You can create directly multiline strings with the caret (one empty line is required).

setlocal EnableDelayedExpansion
set multiLine=This is a ^

multiline text^

line3
echo !multiLine!

或者你可以先创建一个换行符。

Or you can create first a newline character.

setlocal EnableDelayedExpansion
set LF=^


rem Two empty lines are required
set multiLine=This is a!LF!multiline text!LF!line3
echo !multiLine!

这是解释如何工作可以在<一个找到href=\"http://stackoverflow.com/questions/6379619/explain-how-dos-batch-newline-variable-hack-works/6379861#6379861\">Explain DOS的批处理换行的变量黑客是如何工作的

An explanation how this works can be found at Explain how dos-batch newline variable hack works

这篇关于DOS:多行字符串工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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