Powershell: Get-Content -Raw returns only the last line if it is CR

Created on 8 Jan 2020  路  1Comment  路  Source: PowerShell/PowerShell

Steps to reproduce

$bytes = Write-Output 49 13 50 13 51 13 52 13 53
[IO.File]::WriteAllBytes("cr.txt", $bytes)
Get-Content -Raw cr.txt

Expected behavior

1
2
3
4
5

Actual behavior

5

Environment data

Windows 10 / PowerShell 7.0.0-rc.1
Area-Cmdlets-Core Issue-Bug Up-for-Grabs

Most helpful comment

It is not a bug in Get-Content. Rather, the carriage return characters are output to the console, which then moves the cursor back to the beginning of the line and starts overwriting previous output.

PS C:\> "eight`rr"
right

>All comments

It is not a bug in Get-Content. Rather, the carriage return characters are output to the console, which then moves the cursor back to the beginning of the line and starts overwriting previous output.

PS C:\> "eight`rr"
right
Was this page helpful?
0 / 5 - 0 ratings

Related issues

DarwinJS picture DarwinJS  路  65Comments

Ciantic picture Ciantic  路  90Comments

SteveL-MSFT picture SteveL-MSFT  路  189Comments

dragonwolf83 picture dragonwolf83  路  127Comments

ephos picture ephos  路  65Comments