中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-26 18:22
47,813 topics / 349,918 posts / today 0 new / 48,276 members
DOS批处理 & 脚本技术(批处理室) » Can one echo output multiple lines?
Printable Version  4,256 / 18
Floor1 junyee Posted 2007-11-26 10:36
中级用户 Posts 112 Credits 253
echo (1&2&3)>test.txt
Floor2 fastslz Posted 2007-11-26 11:13
铂金会员 Posts 2,315 Credits 5,493 From 上海
The following code is saved as echo2.cmd


When executing
echo2 abc def ghi
or echo2 abc def ghi>test.txt
Floor3 junyee Posted 2007-11-26 11:27
中级用户 Posts 112 Credits 253
Thanks to the enthusiasm of the person above, but unfortunately it's not the result I wanted~

This can also be achieved
@echo off
set /p input=
for %%a in (%input%) do echo %%a>>test.txt

I just want to ask if echo has such a function, a single command to output multiple lines
Also: It's rare to see the application of shift...

[ Last edited by junyee on 2007-11-26 at 11:28 AM ]
Floor4 fastslz Posted 2007-11-26 11:35
铂金会员 Posts 2,315 Credits 5,493 From 上海
No reliance on echo2.cmd, there's no other way except for
echo2.cmd is more convenient to use than yours
echo2 line 1 content (space) line 2 content (space) line 3 content.....
Floor5 lxmxn Posted 2007-11-26 12:19
版主 Posts 4,938 Credits 11,386
E:\Cmd>type xecho.bat
@echo this is the first line for echo^

this is the second line^

the end
E:\Cmd>xecho.bat
this is the first line for echo
this is the second line
the end

E:\Cmd>
Floor6 ldd600 Posted 2007-11-26 18:58
新手上路 Posts 3 Credits 6
Wow, the person upstairs is really good!
It turns out that adding a ^ at the end of the line and then leaving a blank line below works.
I tried it and it's pretty good.
Floor7 HAT Posted 2007-11-27 01:23
版主 Posts 5,017 Credits 9,023
Can moderator lxmxn explain the principle?
Floor8 scriptor Posted 2007-11-27 01:46
银牌会员 Posts 555 Credits 1,187
^When it first appears, it means to escape the following character
Floor9 vkill Posted 2007-12-22 20:57
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Does the next line also count as subsequent characters?
Floor10 wuxj Posted 2007-12-23 02:34
初级用户 Posts 25 Credits 50
The moderator is indeed powerful
Floor11 zyz0304360 Posted 2008-01-15 13:11
中级用户 Posts 123 Credits 257 From 烟台
Learning
Floor12 kidzgy Posted 2008-01-15 18:54
中级用户 Posts 129 Credits 262
Moderator, if there are multiple lines and spaces are needed in the middle, how to do it?
Floor13 tempuser Posted 2008-01-16 17:07
高级用户 Posts 261 Credits 547
echo2 123 456 789
Not implemented
123
456
789
Display effect!
Floor14 lxmxn Posted 2008-01-18 01:22
版主 Posts 4,938 Credits 11,386
Originally posted by kidzgy at 2008-1-15 18:54:
Moderator, if there are multiple lines and spaces are needed in the middle, what should be done?

B:\PERL>type xecho.bat
@echo one^

^

^

the end^
goodbye
B:\PERL>xecho.bat
one


the end goodbye

B:\PERL>
Floor15 shi1035 Posted 2008-01-18 09:29
新手上路 Posts 4 Credits 7
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023