本文介绍了在没有dos2unix的情况下递归转换目录和子目录中所有文件的所有EOL(dos-> unix)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在无 dos2unix中递归转换目录和子目录中所有文件的所有EOL(dos-> unix)? (我没有它,无法安装.)
How do I convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix? (I do not have it and cannot install it.)
有没有一种方法可以使用tr -d '\r'和管道?如果可以,怎么办?
Is there a way to do it using tr -d '\r' and pipes? If so, how?
推荐答案对于当前目录中的所有文件,您都可以使用Perl单行代码执行:perl -pi -e 's/\r\n/\n/g' *(从此处)
For all files in current directory you can do it with a Perl one-liner: perl -pi -e 's/\r\n/\n/g' * (stolen from here)
编辑:只需稍作修改,就可以进行子目录递归:
EDIT: And with a small modification you can do subdirectory recursion:
find | xargs perl -pi -e 's/\r\n/\n/g'更多推荐
在没有dos2unix的情况下递归转换目录和子目录中所有文件的所有EOL(dos
发布评论