简体   繁体   中英

Multiple new lines in batch?

@echo off
Set /A number=1 & goto loop

:loop

echo= line %number% > output.txt
:: #So here is where I'd like to make a new paragraph to continue my loop
Set /A number= %number% + 1
if %number% EQU 21 exit

goto loop

So output.txt now is line 20.

What I need here is line 1 line 2 line 3 and so on until 20

A single line in a batch file:

@(For /L %%A In (1,1,20) Do @Echo(line %%A)>output.txt

A single line in the Command Prompt

(For /L %A In (1,1,20) Do @Echo(line %A)>output.txt

When you make > to file it creates new file. If you need to add to file use >>. So you can make

echo= start > output.txt

before loop and

echo= line %number% >> output.txt

inside loop

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM