Link to home
Start Free TrialLog in
Avatar of Luke Toulmin-Rothe
Luke Toulmin-Rothe

asked on

Powershell script to remove white space

Hi,

I am after a script that will read a text file and delete any white space that is = to 2 characters or greater in my file. I need to read down all lines and remove the white space, please.

Many thanks

Luke
Avatar of Qlemo
Qlemo
Flag of Germany image

Can you show example in/output, best posting files we can test with?
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This does it recursively for each line
Get-Content C:\Temp\input.txt | do { % {$_ -replace "  ", " "}; while ($_ -match "  " | Set-Content C:\Temp\output.txt

Open in new window