Reputation: 8140
I would expect the following powershell command:
echo 'abc' > /test.txt
to fill the file /test.txt
with exactly 3 bytes: 0x61, 0x62, 0x63
.
If I inspect the file, I see that its bytes are (all values are hex):
ff fe 61 00 62 00 63 00 0d 00 0a 00
Regardless of what output I try to stream into a file, the following steps apply in the given order, transforming the resulting file contents:
\r\n
(0d 0a
) to the end of the output00
) after every character of the outputff fe
to the entire outputTransformation #1 is relatively tolerable, but the other two transformations are a real pain.
How can I stream content more precisely (without these transformations) using powershell?
Thanks!
Upvotes: 2
Views: 905
Reputation: 309
Try this
'abc' | out-file -filepath .\test.txt -encoding ascii -nonewline
should get you 3 bytes instead of 12
61 62 63
Upvotes: 3