且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows批处理:echo没有新行

更新时间:2023-12-04 13:01:22

使用 set / p 参数,你可以不用换行符来回显:

  C:\> echo Hello World 
Hello World

C:\> echo | set / p =Hello World
Hello World
C:\>


What is the Windows batch equivalent of the Linux shell command echo -n which suppresses the newline at the end of the output?

The idea is to write on the same line inside a loop.

Using set and the /p parameter you can echo without newline:

C:\> echo Hello World
Hello World

C:\> echo|set /p="Hello World"
Hello World
C:\>

Source