如何在整个目录上运行dos2unix?

本文翻译自:How can I run dos2unix on an entire directory?

I have to convert an entire directory using dos2unix . 我必须使用dos2unix转换整个目录。 I am not able to figure out how to do this. 我不知道该怎么做。


#1楼

参考:https://stackoom.com/question/O3oF/如何在整个目录上运行dos-unix


#2楼

find . -type f -print0 | xargs -0 dos2unix

将递归地查找当前目录中的所有文件,并调用这些文件dos2unix命令


#3楼

如果没有子目录,也可以

ls | xargs -I {} dos2unix "{}"

#4楼

If it's a large directory you may want to consider running with multiple processors: 如果目录很大,则可能要考虑在多个处理器上运行:

find . -type f -print0 | xargs -0 -n 1 -P 4 dos2unix 

This will pass 1 file at a time, and use 4 processors. 一次将传递1个文件,并使用4个处理器。


#5楼

As I happened to be poorly satisfied by dos2unix, I rolled out my own simple utility. 由于恰好对dos2unix不满意,我推出了自己的简单实用程序。 Apart of a few advantages in speed and predictability, the syntax is also a bit simpler : 除了在速度和可预测性方面的一些优势外,语法也更加简单:

endlines unix *

And if you want it to go down into subdirectories (skipping hidden dirs and non-text files) : 如果您希望它进入子目录(跳过隐藏的目录和非文本文件):

endlines unix -r .

endlines is available here https://github.com/mdolidon/endlines 可以在这里找到endlines https://github.com/mdolidon/endlines


#6楼

For any Solaris users (am using 5.10, may apply to newer versions too, as well as other unix systems): 对于任何Solaris用户(上午使用5.10,也可能适用于较新版本以及其他UNIX系统):

dos2unix doesn't default to overwriting the file, it will just print the updated version to stdout, so you will have to specify the source and target, ie the same name twice: dos2unix并非默认覆盖文件,它只会将更新的版本打印到stdout,因此您必须指定源和目标,即两次相同的名称:

find . -type f -exec dos2unix {} {} \;
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值