When I tried to read a file using a pipeline, edit the contents, and save it, I got unexpected behavior.
Is this correct behavior by design ?
# Create a text file for testing
PS> 'A' | Out-File -FilePath C:\test.txt
# Read file , modified, overwrite
PS> Get-Content -Path C:\test.txt -Raw | ForEach-Object {$_ + 'B'} | Out-File -FilePath C:\test.txt
# I expect that the output is 'AB', but it outputs nothing
PS> Get-Content -Path C:\test.txt -Raw
When I tried to read a file using a pipeline, edit the contents, and save it, I got unexpected behavior.
Is this correct behavior by design ?