Windows batch: echo without new line

后端 未结 18 1853
失恋的感觉
失恋的感觉 2020-11-22 04:01

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 t

18条回答
  •  面向向阳花
    2020-11-22 04:45

    As an addendum to @xmechanix's answer, I noticed through writing the contents to a file:

    echo | set /p dummyName=Hello World > somefile.txt
    

    That this will add an extra space at the end of the printed string, which can be inconvenient, specially since we're trying to avoid adding a new line (another whitespace character) to the end of the string.

    Fortunately, quoting the string to be printed, i.e. using:

    echo | set /p dummyName="Hello World" > somefile.txt
    

    Will print the string without any newline or space character at the end.

提交回复
热议问题