How to redirect more than one output line into a t

2019-08-19 02:40发布

At the moment I have

echo ping %id% > 1.bat

But I want to copy more than one line of code into another file.

Any ideas?

2条回答
Evening l夕情丶
2楼-- · 2019-08-19 03:24

Option 1 - (same as what Stephan posted)

echo first line >1.bat
echo second line >>1.bat

Option 2

>1.bat (
  echo first line
  echo second line
)

Option 3

call :output >1.bat
exit /b

:output
echo first line
echo second line
exit /b

Options 2 and 3 are significantly faster than option 1 if you are writing lots of output because they only have to open and position the stream pointer once, whereas option 1 must open and position for each line.

查看更多
相关推荐>>
3楼-- · 2019-08-19 03:37
echo first line >1.txt
echo second line >>1.txt
echo third line >>1.txt
...
查看更多
登录 后发表回答