从文本文件

编程入门 行业动态 更新时间:2024-10-25 10:24:23
文本文件 - sed,其他bash / shell方法中删除unicode字符(Remove unicode characters from textfiles - sed , other bash/shell methods)

如何从终端上的一堆文本文件中删除unicode字符? 我已经尝试过了,但它没有工作:

sed 'g/\u'U+200E'//' -i *.txt

我需要从文本文件中删除这些unicodes

U+0091 - sort of weird "control" space U+0092 - same sort of weird "control" space A0 - non-space break U+200E - left to right mark

How do I remove unicode characters from a bunch of text files on the terminal? I've tried this but it didn't work:

sed 'g/\u'U+200E'//' -i *.txt

I need to remove these unicodes from the textfiles

U+0091 - sort of weird "control" space U+0092 - same sort of weird "control" space A0 - non-space break U+200E - left to right mark

最满意答案

如果你想删除只有特定的字符,你有python,你可以:

CHARS=$(python -c 'print u"\u0091\u0092\u00a0\u200E".encode("utf8")') sed 's/['"$CHARS"']//g' < /tmp/utf8_input.txt > /tmp/ascii_output.txt

If you want to remove ONLY particular characters and you have python, you can:

CHARS=$(python -c 'print u"\u0091\u0092\u00a0\u200E".encode("utf8")') sed 's/['"$CHARS"']//g' < /tmp/utf8_input.txt > /tmp/ascii_output.txt

更多推荐

本文发布于:2023-04-29 04:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335246.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!