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:
— Select —
站务公告 & 版主讨论
意见反馈 & 网友交流
DOS学习入门 & 精彩文章 (教学室)
DOS疑难解答 & 问题讨论 (解答室)
DOS启动盘 & LOGO技术 (启动盘室)
DOS批处理 & 脚本技术(批处理室)
DOS媒体世界 & 网络技术 (多媒体室)
DOS汉化世界 & 中文系统 (中文化室)
DOS开发编程 & 发展交流 (开发室)
DOS软件下载 & 游戏分享 (下载室)
GRUB4DOS、SYSLINUX及其它启动管理软件讨论专区
其它操作系统综合讨论区
WinPE、PowerShell及其它命令行系统专区
贴图灌水、文学娱乐专区
网络日志(Blog)
论坛回收站
├ 链接失效,待修正