`echo 123 > out.txt` equivalent on windows command line?

The closest I can come up with is:

echo 123 > out.txt

However this gives a trailing space and also a trailing newline.


Solution 1:

http://gnuwin32.sourceforge.net/packages.html

coreutils contains "echo". You can use the "-n" flag to supress the trailing newline

Solution 2:

I've used this with success:

echo|set /p="123" > test.txt

Solution 3:

In PowerShell:

write-output 123 | out-file test.txt

There is no trailing space, but there is a newline.

If you want to do this in cmd, the answer you provided in your question is the "correct" way, but there are obvious formatting issues