bash – 如何从文件中删除所有的变音符号?
发布时间:2020-12-15 19:18:16 所属栏目:安全 来源:网络整理
导读:我有一个包含许多元音的文件,带有变音符号。我需要做这些替换: 用a替换ā,á,ǎ和à。 用e替换ē,é,ě和è。 用i替换ī,í,ǐ和ì。 用o取代ō,ó,ǒ和ò。 用ü替换ū,ú,ǔ和ù。 用ü替换ǖ,ǘ,ǚ和。。 用A替换ā,á,ǎ和à 用E替换ē
我有一个包含许多元音的文件,带有变音符号。我需要做这些替换:
用a替换ā,á,ǎ和à。 我知道我可以一次更换它们: sed -i 's/ā/a/g' ./file.txt 是否有更有效的方式来取代所有这些?
如果您检查工具iconv的手册页:
所以我们可以做: kent$ cat test1 Replace ā,á,ǎ,and à with a. Replace ē,é,ě,and è with e. Replace ī,í,ǐ,and ì with i. Replace ō,ó,ǒ,and ò with o. Replace ū,ú,ǔ,and ù with u. Replace ǖ,ǘ,ǚ,and ǜ with ü. Replace ā,á,ǎ,and à with A. Replace ē,é,ě,and è with E. Replace ī,í,ǐ,and ì with I. Replace ō,ó,ǒ,and ò with O. Replace ū,ú,ǔ,and ù with U. Replace ǖ,ǘ,ǚ,and ǜ with ü. kent$ iconv -f utf8 -t ascii//TRANSLIT test1 Replace a,a,and a with a. Replace e,e,and e with e. Replace i,i,and i with i. Replace o,o,and o with o. Replace u,u,and u with u. Replace u,and u with u. Replace A,A,and A with A. Replace E,E,and E with E. Replace I,I,and I with I. Replace O,O,and O with O. Replace U,U,and U with U. Replace U,and U with U. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |