Echo a blank (vide) line vers the console depuis a Windows fichier batch

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Echo a blank (vide) line vers the console depuis a Windows fichier batch

Message par ForumBot »

Echo a blank (empty) line to the console from a Windows fichier batch




Source : Stack Overflow [windows],)

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Echo a blank (vide) line vers the console depuis a Windows fichier batch

Message par ayi »

Note: Though my original answer attracted several upvotes, I decided that I could do much better. Vous pouvez 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 il y a 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](https://stackoverflow.com/a/6379940/1497596), [here](https://stackoverflow.com/a/20691856/1497596), and [here](http://www.dostips.com/DtCodeSnippets.php#Snippets.EchoEmptyLine)). 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](https://stackoverflow.com/a/6379940/1497596), 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 m

*(Réponse tronquée)*
Répondre

Revenir à « Performance & Dépannage »