中国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-08-25 23:42
47,812 topics / 349,910 posts / today 0 new / 48,264 members
DOS批处理 & 脚本技术(批处理室) » Ask how to concatenate text?
Printable Version  1,920 / 6
Floor1 lovecissi Posted 2006-06-23 21:52
初级用户 Posts 8 Credits 40
I have two files:
1.txt with content: 111111
2.txt with content: 222222

When I use type d:\1.txt >> 2.txt, the content of 2.txt is displayed as 2222221111111.

How can I insert a carriage return between them so that the content of 2.txt is:
222222
111111

Please teach the seniors?
Floor2 不得不爱 Posted 2006-06-24 11:39
超级版主 Posts 2,044 Credits 5,310 From 四川南充
That's caused by not inserting line breaks in 1.txt and 2.txt!
You can use the following command:
type 2.txt|find/v "">3.txt
del 2.txt
ren 3.txt 2.txt
type 1.txt|find/v "">>2.txt
Floor3 lovecissi Posted 2006-06-24 12:35
初级用户 Posts 8 Credits 40
Thank you very much~~~~Thank you very much~~~~~You are my benefactor
Floor4 bagpipe Posted 2006-06-24 15:13
银牌会员 Posts 425 Credits 1,144 From 北京
This should also be okay: more <d:\1.txt>> 2.txt
Floor5 flysp Posted 2006-06-24 20:42
中级用户 Posts 41 Credits 207
for /f %i in (d:\1.txt) do @echo %i >>d:\2.txt
Floor6 willsort Posted 2006-06-24 22:39
元老会员 Posts 1,512 Credits 4,432
Re Upstairs:

The above answers from everyone have complicated the problem. A single carriage return can be added using echo alone.

echo.>>2.txt
type d:\1.txt >> 2.txt
Floor7 amao Posted 2007-02-03 13:59
中级用户 Posts 152 Credits 316
sed "r 1.txt" 2.txt

It doesn't matter whether there is a carriage return at the end of the original text in 2.txt or not

[ Last edited by amao on 2007-2-3 at 02:01 PM ]
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023