Pierre-olivier Gendraud
Pierre-olivier Gendraud

Reputation: 1937

How to use a method with a pipe operator

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.

code

Upvotes: 0

Views: 60

Answers (1)

Pierre-olivier Gendraud
Pierre-olivier Gendraud

Reputation: 1937

As boxdog proposed, this works for my case:

(cat a.txt) -replace '\s+', ' ' | echo

code

Upvotes: 1

Related Questions