1

What would be a way to remove temporary output from piped Out-File in Powershell?

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:

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.

Soid
  • 2,585
  • 1
  • 30
  • 42

1 Answers1

1

If you have WSL installed, you could try 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
mklement0
  • 382,024
  • 64
  • 607
  • 775