Powershell: Update current output line

后端 未结 2 1740
鱼传尺愫
鱼传尺愫 2021-02-20 16:20

is there a way to update the current line of the command output in powershell?

i know how to write to the same line:

Write-Host \"hello \" -NoNewLine

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-20 17:10

    Use carriage return to return to the start of the line: `r

    See this: http://ss64.com/ps/syntax-esc.html

    And definition of carriage return: http://en.wikipedia.org/wiki/Carriage_return

    If you want to clear a line, that and a load of spaces. Otherwise you can overwrite stuff.

    I can't really write up an example here as it's SO's code character, but put it at the start of the "world" string and it should work.

    Hope this helps!

提交回复
热议问题