免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6388 | 回复: 2
打印 上一主题 下一主题

关于将windows下的文件换行符转为unix换行符 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-09-03 16:27 |只看该作者 |倒序浏览
在windows下文件的换行符\n用16进制看是“0D 0A”,在unix下是“0A”。
不知道怎么将文件转为unix下的换行符啊?perl程序是要在windos下面跑的。
---------------------------------------------------------
脚本代码:
#!user/bin/perl -w

open(DBFILE,">tmpperl.txt") || die "警告:打开tmpperl.txt文件失败!$!\n";
print DBFILE "hello\n";
print DBFILE "work\n";

close(DBFILE);
----------------------------------------------------------
windows下的结果:
00000000h: 68 65 6C 6C 6F 0D 0A 77 6F 72 6B 0D             ; hello..work.

unix下的结果:
00000000h: 68 65 6C 6C 6F 0A 77 6F 72 6B 0A                ; hello.work.

[ 本帖最后由 globlefly 于 2007-9-3 16:36 编辑 ]

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
2 [报告]
发表于 2007-09-03 21:22 |只看该作者
改一下$\就好啦....

$\
The output record separator for the print operator. If defined, this value is printed after the last of print's arguments. Default is undef. (Mnemonic: you set $\ instead of adding "\n" at the end of the print. Also, it's just like $/, but it's what you get "back" from Perl.)

论坛徽章:
0
3 [报告]
发表于 2007-09-05 16:48 |只看该作者
大侠,我还是看不懂应该如何写啊。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP