Windows batch: echo without new line

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

    Use EchoX.EXE from the terrific "Shell Scripting Toolkit" by Bill Stewart
    How to suppress the linefeed in a Windows Cmd script:

    @Echo Off
    Rem Print three Echos in one line of output
    EchoX -n "Part 1 - "
    EchoX -n "Part 2 - "
    EchoX    "Part 3"
    Rem
    

    gives:

    Part 1 - Part 2 - Part 3
    {empty line}
    d:\Prompt>
    

    The help for this usage is:

    Usage: echox [-n] message
      -n       Do not skip to the next line.
      message  The text to be displayed.
    

    The utility is smaller than 48K, and should live in your Path. More things it can do:
    - print text without moving to the next line
    - print text justified to the left, center, or right, within a certain width
    - print text with Tabs, Linefeeds, and Returns
    - print text in foreground and background colors

    The Toolkit includes twelve more great scripting tricks.
    The download page also hosts three other useful tool packages.

提交回复
热议问题