使用sed从文件中删除多字节字符 [英] removing multibyte characters from a file using sed

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

问题描述

我需要从文件中删除所有多字节字符,我不知道它们是什么,所以我需要覆盖整个范围.

i need to remove all multibyte characters from a file, i dont know what they are so i need to cover the whole range.

我可以像这样使用 grep 找到它们:grep -P "[\x80-\xFF]" '我的文件'

I can find them using grep like so: grep -P "[\x80-\xFF]" 'myfile'

尝试用 sed 做一个类似的事情,但删除它们.

Trying to do a simular thing with sed, but delete them instead.

干杯

推荐答案

试试这个:

LANG=C sed 's/[\x80-\xFF]//g' filename

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

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