易截截图软件、单文件、免安装、纯绿色、仅160KB

Windows和Linux间文本文件格式转换

问题:在Linux下正常换行的文字,到了Windows下后,不再换行。
 
在Windows下换行时,有两个字符:回车(\r)和换行(\n)。但在Linux下,只有一个换行(\n)
可使用unix2dos和dos2unix命令进行格式的转换:
参数:
-k  保持输出文件和输入文件的日期时间戳不变
-o file   默认模式 . 将file转换,并输出到file
-n  infile outfile 新模式. 转换infile, 并输出到outfile
 
 
1.       unix2dos
 
假设用vi新建一文本文件,输入123456
[root@centos test]# ls -l a.txt
-rw-r--r-- 1 root root 7 Jan  7 21:31 a.txt
[root@centos test]# hexdump -c a.txt
0000000   1   2   3   4   5   6  \n
0000007
[root@centos test]# unix2dos -n a.txt b.txt
unix2dos: converting file a.txt to file b.txt in DOS format ...
[root@centos test]# ls -l
total 8
-rw-r--r-- 1 root root 7 Jan  7 21:31 a.txt
-rw------- 1 root root 8 Jan  7 21:34 b.txt
[root@centos test]# hexdump -c a.txt
0000000   1   2   3   4   5   6  \n
0000007
[root@centos test]# hexdump -c b.txt
0000000   1   2   3   4   5   6  \r  \n
0000008
b.txt是转换后的DOS下的文件
 
2.       dos2unix
[root@centos test]# dos2unix -n b.txt c.txt
dos2unix: converting file b.txt to file c.txt in UNIX format ...
[root@centos test]# ls -l
total 12
-rw-r--r-- 1 root root 7 Jan  7 21:31 a.txt
-rw------- 1 root root 8 Jan  7 21:34 b.txt
-rw------- 1 root root 7 Jan  7 21:38 c.txt
[root@centos test]# hexdump -c b.txt
0000000   1   2   3   4   5   6  \r  \n
0000008
[root@centos test]# hexdump -c c.txt
0000000   1   2   3   4   5   6  \n
0000007
c.txt是转换后unix下的文本文件
 


相关文档:

实战Linux Bluetooth编程 (七) SDP协议

Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......

uc/OS与Linux的比较

    
随着现代计算机技术的飞速发展和互联网技术的广泛应用,从pc时代过渡到了以个人数字助理、手持个人电脑和信息家电为代表的3c(计算机、通信、消费电
子)一体的后pc时代。后pc时代里,嵌入式系统扮演了越来越重要的角色,被广泛应用于信息电器、移动计算机设备、网络设备和工控仿真等领域。嵌入式 ......

怎么在Linux中添加新的系统调用

系统调用是应用程式和操作系统内核之间的功能接口。其主要目的是使得用户
能使用操作系统提供的有关设备管理、输入/输入系统、文件系统和进程控制、
通信及存储管理等方面的功能,而不必了解系统程式的内部结构和有关硬件细
节,从而起到减轻用户负担和保护系统及提高资源利用率的作用。
  Linux操作系统作为免费软件 ......

Linux 2.6内核的新锁机制 RCU

http://www.ibm.com/developerworks/cn/linux/l-rcu/
函数摘要:
C代码
/*读者在读取由RCU保护的共享数据时使用该函数标记它进入读端临界区。*/ 
rcu_read_lock()  
/* 
该函数与rcu_read_lock配对使用,用以标记读者退出读端临界区。夹在这两个函数之间的代码区称为"读端临界区" ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号