How can you you insert a newline from your batch file output?
I want to do something like:
> echo hello\nworld
Which would output:
hello
world
How can you you insert a newline from your batch file output? I want to do something like:
Which would output:
|
|||||||||
|
This means you could define |
|||||||||||||||||||||
|
use
|
|||||||||||||||||||||
|
Here you go, create a .bat file with the following in it:
You should see output like the following:
You only need the code between the REM statements, obviously. |
|||||||||||||||||||||
|
There is a standard feature
Output of cited above cmd-file:
|
|||||||||||||||||||||
|
Like the answer of Ken, but with the use of the delayed expansion.
First a single linefeed character is created and assigned to the LF-variable. The advantage of using the delayed expansion is, that there is no special character handling at all. More explanations are at |
|||||
|
When echoing something to redirect to a file, multiple echo commands will not work. I think maybe the ">>" redirector is a good choice: echo hello > temp echo world >> temp |
|||||||||
|
Just like Grimtron suggests - here is a quick example to define it:
Output
|
|||||||||||||||||
|
If you need it in a single line, use the
would output as:
|
|||||
|
If you need to put results to a file, you can use
|
|||
|
You can also do like this,
The output will be,
Note that when this is put in a batch file, '%' shall be doubled.
|
|||||
|
If anybody comes here because they are looking to echo a blank line from a MINGW make makefile, I used
simply using I hope this helps at least one other person out there :) |
|||
|
This worked for me, no delayed expansion necessary:
It writes output like this:
|
|||||||||
|
You can use Note: The insecable space can be obtained with Alt+0160 Hope it helps :) [edit] Hmm you're right, I needed it in a Makefile, it works perfectly in there. I guess my answer is not adapted for batch files... My bad. |
|||||||||
|
I can't make it any simpler than:
|
||||
|
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?