在没有dos2unix的情况下递归转换目录和子目录中所有文件的所有EOL(dos

编程入门 行业动态 更新时间:2024-10-28 19:35:24
本文介绍了在没有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

本文发布于:2023-10-09 09:22:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1475345.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:递归   情况下   文件   目录   目录中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!