[英]Powershell: Unix' col command equivalent to clean up output?
What would be a way to remove temporary output from piped Out-File
in Powershell?从 Powershell 中的管道
Out-File
中删除临时 output 的方法是什么?
For example, if I run something like:例如,如果我运行类似的东西:
command.exe | Out-File log.txt
if a command showed a changing progress bar in terminal:如果命令在终端中显示不断变化的进度条:
Progress [====================================> ] 58%
then the captured output in file log.txt
shows something like this:然后在文件
log.txt
中捕获的 output 显示如下:
Progress [=> ] 0
Progress [====> ] 5
Progress [========> ] 10
I want it to look in file the same as it shown in terminal.我希望它在文件中的外观与终端中显示的一样。
I'm looking for pretty much the col
command equivalent from Unix as described in this question for Bash.我正在寻找与 Unix 相当的
col
命令,如 Bash 的这个问题中所述。
If you have WSL installed, you could try command.exe | wsl.exe col -b > log.txt
如果你安装了 WSL,你可以试试
command.exe | wsl.exe col -b > log.txt
command.exe | wsl.exe col -b > log.txt
Otherwise, as a suboptimal ad hoc solution, you could try to filter out the unwanted lines by matching their content:否则,作为次优的临时解决方案,您可以尝试通过匹配内容来过滤掉不需要的行:
@(command.exe) -notmatch '^Progress \[' | Out-File log.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.