How to prevent Powershell from assuming 80 columns width output when redirecting output on Linux

Viewed 50

When i execute the following PowerShell script on Linux:

dir

In the following way:

pwsh test.ps1 > output.txt

The output in output.txt is limited to 80 columns.

How can i prevent this behavior? Modifying $host.UI.RawUI.BufferSize is not supported on Linux.

1 Answers

I think pwsh with output redirected will just assume a standard file width.

But you can set a width inside pwsh.

PS> .\test1.ps1 | Out-File z -Width 60

or

pwsh -c ".\test1.ps1 | Out-File z -Width 60"
Related