CMD Echo Command saves only the last line of text

I create a batch file and am having problems with the following command:

    echo Hello & echo.World > Text.txt

Whenever I do this command, only the last line is displayed in the output:

World

But if I just do the above command in CMD without writing to a file, it will appear perfectly on the command line. I have full access to my file, but I still can not write all the text.

+4
source share
2 answers

> , &, echo.World . .

, .

(echo Hello & echo.World) > Text.txt
+6

& . , echo.

echo echo.World > Text.txt

,

echo Hello  echo.World > Text.txt

Hello World ( , Hello ...)

, > , >> ( ),

echo Hello > Text.txt
echo.World > Text.txt

Hello new, World.

,

echo Hello > Text.txt
echo.World >> Text.txt

, ,

echo Hello > Text.txt&echo.World >> Text.txt

(aka "block" ) ,

(echo Hello &echo.World)> Text.txt

, ,

(echo Hello &echo.World)>> Text.txt

.

, >.

> >>. , ,

echo Hello 1> Text.txt

hello Space .

, Space, , , , . , > , " output will be used. The useful ones here are 1 (standard output) and 2(standard error) so you can redirect errormessages using 2 > errorreports.txt` .

, ,

> Text.txt echo Hello 1
+3

Source: https://habr.com/ru/post/1618037/


All Articles