如何使用sed删除\ r字符 [英] How to remove \r character with sed

查看:141
本文介绍了如何使用sed删除\ r字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单,我有一个在每个换行符处都有\ r \ n的文件.

Very simply I have a file that has \r\n at every line break.

aaaa\r\nbbbb\r\ncccc

我想在保留\ n的同时删除\ r字符.

I would like to remove the \r character while leaving the \n in place.

我可以在python中轻松完成此操作,但使用简单的sed命令似乎更优雅.这可能吗?什么表情可以解决问题?我似乎在网上找不到任何这样的解决方案.

I could do this easily in python but it seems to be more elegant with a simple sed command. Is this possible? What expression would do the trick? I can't seem to find any such solution online.

谢谢

推荐答案

您应该可以使用 sed 这样来做到这一点:

You should be able to do it with sed like this:

sed 's/\r//g' orig.txt > modified.txt

这篇关于如何使用sed删除\ r字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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