Add a new line to a text file in MS-DOS

后端 未结 6 1069
攒了一身酷
攒了一身酷 2020-12-24 05:11

I am making a .bat file, and I would like it to write ASCII art into a text file.

I was able to find the command to append a new line to the file when e

相关标签:
6条回答
  • 2020-12-24 05:42
    echo "text to echo" > file.txt
    
    0 讨论(0)
  • 2020-12-24 05:55

    You can easily append to the end of a file, by using the redirection char twice (>>).


    This will copy source.txt to destination.txt, overwriting destination in the process:

    type source.txt > destination.txt
    

    This will copy source.txt to destination.txt, appending to destination in the process:

    type source.txt >> destination.txt
    
    0 讨论(0)
  • 2020-12-24 05:56

    Maybe this is what you want?

    echo foo > test.txt
    echo. >> test.txt
    echo bar >> test.txt
    

    results in the following within test.txt:

    foo

    bar

    0 讨论(0)
  • 2020-12-24 06:04
    echo Hello, > file.txt
    echo.       >>file.txt
    echo world  >>file.txt
    

    and you can always run:

    wordpad file.txt
    

    on any version of Windows.


    On Windows 2000 and above you can do:

    ( echo Hello, & echo. & echo world ) > file.txt
    

    Another way of showing a message for a small amount of text is to create file.vbs containing:

    Msgbox "Hello," & vbCrLf & vbCrLf & "world", 0, "Message"
    

    Call it with

    cscript /nologo file.vbs
    

    Or use wscript if you don't need it to wait until they click OK.


    The problem with the message you're writing is that the vertical bar (|) is the "pipe" operator. You'll need to escape it by using ^| instead of |.

    P.S. it's spelled Pwned.

    0 讨论(0)
  • 2020-12-24 06:04

    Use the following:

    echo (text here) >> (name here).txt
    

    Ex. echo my name is jeff >> test.txt

    test.txt

    my name is jeff
    

    You can use it in a script too.

    0 讨论(0)
  • 2020-12-24 06:07
    • I always use copy con to write text, It so easy to write a long text
    • Example:

      C:\COPY CON [drive:][path][File name]

      .... Content

      F6

      1 file(s) is copied

    0 讨论(0)
提交回复
热议问题