Home  >  Article  >  php教程  >  Linux 批量处理dos2unix

Linux 批量处理dos2unix

WBOY
WBOYOriginal
2016-06-06 20:00:181026browse

在 windows 下编辑过的文件一般都会被保存为 dos 式, 而 mac os x 和 *nix 类系统一般都是使用 unix 式, 在windows下编辑过的文件在*nix下打开,会被加上^M, 然后造成程序出问题。 所以需要将文件的式从dos转换成unix. 可以使用的工具是dos2unix,使用命令如

在 windows 下编辑过的文件一般都会被保存为 dos 格式, 而 mac os x 和 *nix 类系统一般都是使用 unix 格式,

在windows下编辑过的文件在*nix下打开,会被加上^M, 然后造成程序出问题。

所以需要将文件的格式从dos转换成unix.


可以使用的工具是dos2unix,使用命令如下:

Linux 批量处理dos2unix


因为文件的数量太大,所以需要批量的来导。

这里就可以使用find 命令。

find . -type f
上面这个命令可以找出所以的文件在当前目录下。


然后使用-exec参数 来运行某些命令。

find . -type f -exec dos2unix {} \;

注意dos2unix与{}之间有一个空格。




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn