Reputation: 1937
This command returns the expected result
'd d' -replace '\s+', ' ' | echo
'd d'
Now I want ot use this method replace on the content of a file.
new-Item a.txt
echo 'd d' >a.txt
cat a.txt| -replace '\s+', ' ' | echo
-replace : The term '-replace' is not recognized as the name of a cmdlet, function, script file, or operable program.
Upvotes: 0
Views: 60
Reputation: 1937
As boxdog proposed, this works for my case:
(cat a.txt) -replace '\s+', ' ' | echo
Upvotes: 1