Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 369 Vote(s) - 3.41 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Echo a blank (empty) line to the console from a Windows batch file

#1
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?
Reply

#2
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.
Reply

#3
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][1].

[1]:

[To see links please register here]

Reply

#4
<!-- language-all: none -->

*<sup>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.</sup>*

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][1], [here][2], and [here][3]). 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](

[To see links please register here]

), 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][4].

---

echo(
echo+
echo,
echo/
echo;
echo=
echo[
echo]

[This lengthy discussion](

[To see links please register here]

) includes what I believe to be all of these. Several of these options are recommended in [this SO answer](

[To see links please register here]

) as well. Within the cited discussion, [this post](

[To see links please register here]

) 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](

[To see links please register here]

), [@jeb][5] 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.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

[4]:

[To see links please register here]

[5]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through