How do I create a multiline text file with Echo in Windows command prompt?

There are three ways.

  1. Append each line using >>:

    C:\Users\Elias>echo foo > a.txt
    C:\Users\Elias>echo bar >> a.txt
    
  2. Use parentheses to echo multiple lines:

    C:\Users\Elias>(echo foo
    More? echo bar) > a.txt
    
  3. Type caret (^) and hit ENTER twice after each line to continue adding lines:

    C:\Users\Elias>echo foo^
    More?
    More? bar > a.txt
    

All the above produce the same file:

C:\Users\Elias>type a.txt
foo
bar

You could use the >> characters to append a second line to the file, e.g.

echo hello > myfile.txt
echo second line >> myfile.txt