Windows batch: echo without new line

后端 未结 18 1412
失恋的感觉
失恋的感觉 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:58

    Sample 1: This works and produces Exit code = 0. That is Good. Note the "." , directly after echo.

    C:\Users\phife.dog\gitrepos\1\repo_abc\scripts #
    @echo.| set /p JUNK_VAR=This is a message displayed like Linux echo -n would display it ... & echo %ERRORLEVEL%

    This is a message displayed like Linux echo -n would display it ... 0

    Sample 2: This works but produces Exit code = 1. That is Bad. Please note the lack of ".", after echo. That appears to be the difference.

    C:\Users\phife.dog\gitrepos\1\repo_abc\scripts #
    @echo | set /p JUNK_VAR=This is a message displayed like Linux echo -n would display it ... & echo %ERRORLEVEL%

    This is a message displayed like Linux echo -n would display it ... 1

提交回复
热议问题