gpt4 book ai didi

bash - 转换行结尾

转载 作者:太空宇宙 更新时间:2023-11-04 04:02:25 25 4
gpt4 key购买 nike

我一直在使用d2u转换行结尾。安装 Puppy Linux 后,我注意到它没有附带 d2u ,但是dos2unix 。然后我注意到 Ubuntu 默认情况下缺少这两者。

转换行结尾的另一种方法是什么?

最佳答案

一些选项:

使用tr

tr -d '\15\32' < windows.txt > unix.txt

tr -d '\r' < windows.txt > unix.txt 

使用perl

perl -p -e 's/\r$//' < windows.txt > unix.txt

使用sed

sed 's/^M$//' windows.txt > unix.txt

sed 's/\r$//' windows.txt > unix.txt

要获取^M,您必须先键入CTRL-V,然后键入CTRL-M

关于bash - 转换行结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22539533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com