Windows batch: echo without new line

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

    Inspired by the answers to this question, I made a simple counter batch script that keeps printing the progress value (0-100%) on the same line (overwritting the previous one). Maybe this will also be valuable to others looking for a similar solution.

    Remark: The * are non-printable characters, these should be entered using [Alt + Numpad 0 + Numpad 8] key combination, which is the backspace character.

    @ECHO OFF
    
    FOR /L %%A in (0, 10, 100) DO (     
        ECHO|SET /P="****%%A%%"    
        CALL:Wait 1
    )
    
    GOTO:EOF
    
    :Wait
    SET /A "delay=%~1+1"
    CALL PING 127.0.0.1 -n %delay% > NUL
    GOTO:EOF
    

提交回复
热议问题