When outputting status messages to the console from a Windows batch file, I want to output blank lines to break up the output. How do I do this?
-
9I do not believe that the question [How can you echo a newline in batch files?](http://stackoverflow.com/q/132799/1497596) is a duplicate of this question. The essence of that question is: **Using a single `echo` statement, how can I output two lines of text with a newline between them?** That said, several of the answers to that question also address how to output blank (empty) lines. – DavidRR Dec 22 '13 at 00:01
-
2Since this post is not accepting answers anymore... The correct answer is `echo:` according to the following link. http://ss64.com/nt/echo.html – H2ONaCl Jan 18 '17 at 03:49
-
In summary of the ss64 link posted for `echo`... `echo.` searches for a file named `echo` and only creates a blank line if such a file does not exist. This characteristic makes `echo.` slower and less robust than `echo:`. – u8it Oct 10 '17 at 20:08
3 Answers
Any of the below three options works for you:
echo[
echo(
echo.
For example:
@echo off
echo There will be a blank line below
echo[
echo Above line is blank
echo(
echo The above line is also blank.
echo.
echo The above line is also blank.

- 7,812
- 10
- 34
- 48
-
13Careful, "`echo.`" might not work, see the comments under http://stackoverflow.com/questions/132799/how-can-you-echo-a-newline-in-batch-files#comment51325122_3123194 – Pacerier Jul 29 '15 at 05:51
-
2
Note: Though my original answer attracted several upvotes, I decided that I could do much better. You can find my original (simplistic and misguided) answer in the edit history.
If Microsoft had the intent of providing a means of outputting a blank line from cmd.exe
, Microsoft surely would have documented such a simple operation. It is this omission that motivated me to ask this question.
So, because a means for outputting a blank line from cmd.exe
is not documented, arguably one should consider any suggestion for how to accomplish this to be a hack. That means that there is no known method for outputting a blank line from cmd.exe
that is guaranteed to work (or work efficiently) in all situations.
With that in mind, here is a discussion of methods that have been recommended for outputting a blank line from cmd.exe
. All recommendations are based on variations of the echo
command.
echo.
While this will work in many if not most situations, it should be avoided because it is slower than its alternatives and actually can fail (see here, here, and here). Specifically, cmd.exe
first searches for a file named echo
and tries to start it. If a file named echo
happens to exist in the current working directory, echo.
will fail with:
'echo.' is not recognized as an internal or external command,
operable program or batch file.
echo:
echo\
At the end of this answer, the author argues that these commands can be slow, for instance if they are executed from a network drive location. A specific reason for the potential slowness is not given. But one can infer that it may have something to do with accessing the file system. (Perhaps because :
and \
have special meaning in a Windows file system path?)
However, some may consider these to be safe options since :
and \
cannot appear in a file name. For that or another reason, echo:
is recommended by SS64.com here.
echo(
echo+
echo,
echo/
echo;
echo=
echo[
echo]
This lengthy discussion includes what I believe to be all of these. Several of these options are recommended in this SO answer as well. Within the cited discussion, this post ends with what appears to be a recommendation for echo(
and echo:
.
My question at the top of this page does not specify a version of Windows. My experimentation on Windows 10 indicates that all of these produce a blank line, regardless of whether files named echo
, echo+
, echo,
, ..., echo]
exist in the current working directory. (Note that my question predates the release of Windows 10. So I concede the possibility that older versions of Windows may behave differently.)
In this answer, @jeb asserts that echo(
always works. To me, @jeb's answer implies that other options are less reliable but does not provide any detail as to why that might be. Note that @jeb contributed much valuable content to other references I have cited in this answer.
Conclusion: Do not use echo.
. Of the many other options I encountered in the sources I have cited, the support for these two appears most authoritative:
echo(
echo:
But I have not found any strong evidence that the use of either of these will always be trouble-free.
Example Usage:
@echo off
echo Here is the first line.
echo(
echo There is a blank line above this line.
Expected output:
Here is the first line.
There is a blank line above this line.
-
15`echo.`, `echo:`, echo\, `echo+`, `echo/`, `echo[`, and `echo]` are not safe. When used in a `for /r` loop, e.g. `for /r %a (*) do echo.%a` and so on, they append paths from the previous folder to the next one. `echo(`, `echo,`, `echo;`, and `echo=` do not have this problem. – tomasz86 Jan 14 '19 at 08:13
-
1Update: looks like Microsoft now shows to use "echo." in their Docs to "To echo a blank line on the screen". Echo Doc: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/echo Based on the previous comments/answers it still seems like it would not be recommended to do so though. Unless this behavior has recently changed? – Ben Sep 22 '22 at 03:58
-
`ECHO.` is safe. The problem described is a problem with every command used in Windows when adding a `.` to it. When you _**need**_ to make sure not getting the error, you can always add this to the top of your batch script: `IF EXIST echo. DEL /Q echo.` – Luuk Aug 31 '23 at 07:03
There is often the tip to use 'echo.'
But that is slow, and it could fail with an error message, as cmd.exe will search first for a file named 'echo' (without extension) and only when the file doesn't exists it outputs an empty line.
You could use echo(
. This is approximately 20 times faster, and it works always. The only drawback could be that it looks odd.
More about the different ECHO:/\
variants is at DOS tips: ECHO. FAILS to give text or blank line.

- 30,738
- 21
- 105
- 131

- 78,592
- 17
- 171
- 225
-
3
-
11IMHO it's completely pointless to worry about speed in batch - if your performance bottleneck lies in a batch file you don't try to optimize it - you throw it away to rewrite it in a real language. – Matteo Italia Dec 20 '13 at 05:32
-
4@MatteoItalia, It's nothing to do with speed. If it's doing something extra (search first for a file named `echo` without extension) then it's wrong and if there's a file as such, it'll indeed fail. Extra points if the batchjob fails on a weekend while everyone is partying hard half-a-country away. – Pacerier Jul 29 '15 at 05:53
-
-
1@Pacerier It seems to be the same behaviour from XP to Win10, there are only very small changes since XP at all – jeb Sep 08 '15 at 13:27