bash - 从文本文件中删除 Unicode 字符 - sed ,其他 Bash/shell 方法

标签 bash unicode sed text-files spaces

如何从终端中的一堆文本文件中删除 Unicode 字符?

我已经试过了,但是没用:

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

我需要从文本文件中删除这些 Unicode 字符:

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

最佳答案

清除file.txt的所有非ASCII字符:

$ iconv -c -f utf-8 -t ascii file.txt
$ strings file.txt

选项:

-c # discard unconvertible characters
-f # from ENCODING
-t # to ENCODING

关于bash - 从文本文件中删除 Unicode 字符 - sed ,其他 Bash/shell 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8562354/

相关文章:

linux - 如何创建一个脚本来 grep 用户的两个输入

c++ - 使用 libstdc++ 在字符串、u16string 和 u32string 之间转换

sed - sed 命令中的逗号代表什么?

sed:删除匹配行和之后的所有内容

bash - 使用 bash 脚本在 hadoop 中压缩不同的目录

linux - BASH:如何在命令后的同一行中添加文本

unicode - 我应该在 URL 中使用重音字符吗?

c++ - MSVC++ 中的源字符集编码规范,如 gcc "-finput-charset=CharSet"

linux - 使用 awk 重新格式化日期时间

linux - 如何以正确的方式向 PBS 系统提交工作列表?