alv*_*vas 42 unicode bash spaces sed text-files
如何从终端上的一堆文本文件中删除unicode字符?我试过这个,但它不起作用:
sed 'g/\u'U+200E'//' -i *.txt
Run Code Online (Sandbox Code Playgroud)
我需要从文本文件中删除这些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
Run Code Online (Sandbox Code Playgroud)
kev*_*kev 59
清除所有非ascii字符 file.txt
$ iconv -c -f utf-8 -t ascii file.txt
$ strings file.txt
Run Code Online (Sandbox Code Playgroud)
Mic*_*jer 42
如果你想删除特定字符并且你有python,你可以:
CHARS=$(python -c 'print u"\u0091\u0092\u00a0\u200E".encode("utf8")')
sed 's/['"$CHARS"']//g' < /tmp/utf8_input.txt > /tmp/ascii_output.txt
Run Code Online (Sandbox Code Playgroud)
cho*_*oba 27
对于unicode的utf-8编码,您可以将此正则表达式用于sed:
sed 's/\xc2\x91\|\xc2\x92\|\xc2\xa0\|\xe2\x80\x8e//g'
Run Code Online (Sandbox Code Playgroud)
Mic*_*jer 13
使用iconv:
iconv -f utf8 -t ascii//TRANSLIT < /tmp/utf8_input.txt > /tmp/ascii_output.txt
Run Code Online (Sandbox Code Playgroud)
这会将"Š"等字符翻译成"S"(最相似的字符).
| 归档时间: |
|
| 查看次数: |
75899 次 |
| 最近记录: |