在没有dos2unix的情况下递归转换目录和子目录中所有文件的所有EOL(dos-> unix) [英] Convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix

查看:1059
本文介绍了在没有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-> unix)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆