China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-07 20:57
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Ask how to concatenate text? View 1,858 Replies 6
Original Poster Posted 2006-06-23 21:52 ·  中国 上海 普陀区 电信
初级用户
Credits 40
Posts 8
Joined 2006-05-28 15:30
20-year member
UID 56153
Gender Male
Status Offline
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?
Floor 2 Posted 2006-06-24 11:39 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
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
Floor 3 Posted 2006-06-24 12:35 ·  中国 上海 普陀区 电信
初级用户
Credits 40
Posts 8
Joined 2006-05-28 15:30
20-year member
UID 56153
Gender Male
Status Offline
Thank you very much~~~~Thank you very much~~~~~You are my benefactor
Floor 4 Posted 2006-06-24 15:13 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
This should also be okay: more <d:\1.txt>> 2.txt
Floor 5 Posted 2006-06-24 20:42 ·  中国 河南 郑州 电信
中级用户
Credits 207
Posts 41
Joined 2004-10-24 00:00
21-year member
UID 32885
Gender Male
Status Offline
for /f %i in (d:\1.txt) do @echo %i >>d:\2.txt
Floor 6 Posted 2006-06-24 22:39 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
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
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 7 Posted 2007-02-03 13:59 ·  美国 北达科他州立大学
中级用户
★★
Credits 316
Posts 152
Joined 2006-06-18 13:01
20-year member
UID 57204
Gender Male
Status Offline
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 ]
Forum Jump: