gpt4 book ai didi

linux - 使用 tr/sed 等在 linux 上删除字符序列\r\n

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:53:57 24 4
gpt4 key购买 nike

我正在尝试从文件中删除字符串 '\r\n'

使用sed:

cat foo | sed -e 's/\015\012//'

似乎不起作用。

tr -d '\015' 

将删除单个字符,但我想删除字符串 \015\012。有什么建议吗?

最佳答案

如果我能提供一个 perl 解决方案:

$ printf "a\nb\r\nc\nd\r\ne\n" | perl -0777 -pe 's/\r\n//g' | od -c
0000000 a \n b c \n d e \n
0000010

-0777 选项导致将整个文件作为单个字符串插入。

关于linux - 使用 tr/sed 等在 linux 上删除字符序列\r\n,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24053001/

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