Powershell: echo "" > file.txt VS clear-content file.txt -


depending on how clear file in powershell, garbage.

echo "" > ".\file.txt" or clear-content ".\file.txt" [io.file]::appendalltext("file.txt", "teststring") 

using clear-content, "teststring" in "file.txt".

using echo "" > ".\file.txt", garbage chinese characters.

why? echo "" > file mess encoding?

echo powershell alias write-output.

i'm not sure redirecting output of write-output file resulting in.

i can duplicate results, chinese characters, encoding of file seems ascii (i used function test file encoding: http://poshcode.org/2059).

just running echo "" > ".\file.txt" puts 6 bytes in file: 255, 254, 13, 0, 10, 0 whereas running set-content .\file.txt "" puts 2 bytes: 13, 10.

but understand question is: why command result in output.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -