Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

-replace linebreaks ("`n,"") or ("`r,"") is not working with my Content

$
0
0

Hello everybody,

i'am trying to replace linebreaks from my content which i'm getting from a text file.
But it never replace the linebreaks with nothing. (i can replace spaces..woohooo)

This is what im trying (only e.g.)

$input_path ="C:\input.txt"
$input = Get-Content $input_path
$input_clear = $input -replace " ","" | Out-File "C:\input_clear.txt"

I have allready tried with -replace "'n,""" or "n,""", or "\n","" (same with r).
It replaces the spaces, but never replace the linebreaks ;o(.

PowerShell is always trying to use "'n,""" as a normal text. If i'm trying this he is using exact 'n, when it is in the text file..

How my Powershell ISE will understand 'n or 'r as a linebreak?

 

I'm new to powershell and this is my 2nd script.. Maybe someone could tell me what I'm doing wrong?

Thanks in advance.


Viewing all articles
Browse latest Browse all 6937

Trending Articles