Windows batch: echo without new line

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

    Maybe this is what your looking for, it's a old school script... :P

    set nl=^& echo. 
    echo %nl%The%nl%new%nl%line%nl%is%nl%not%nl%apparent%nl%throughout%nl%text%nl%
    echo only in prompt.
    pause
    

    or maybe your trying to replace a current line instead of writing to a new line? you can experiment with this by removing the "%bs%" after the "." sign and also by spacing out the other "%bs%" after the "Example message".

    for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "bs=%%a"
    

    I find this really interesting because it uses a variable for a purpose other than what it is intended to do. as you can see the "%bs%" represents a backspace. The second "%bs%" uses the backspace to add spaces after the "Example message" to separate the "Pause command's output" without actually adding a visible character after the "Example message". However, this is also possible with a regular percentage sign.

提交回复
热议问题