ascii 不可打印字符
Sometimes the commands’ output have some non-printable ASCII characters. How to filter away these non-printable ASCII characters on Linux?
有时命令的输出包含一些不可打印的ASCII字符。 如何在Linux上过滤掉这些不可打印的ASCII字符?
You can consider the problem as “how to leave only printable ascii characters?”.
您可以将问题视为“如何仅保留可打印的ASCII字符?”。
The printable characters in ASCII table are:
ASCII表中的可打印字符为:
Octal 011: Tab
Octal 012: Line Feed
Octal 015: Carriage Return
Octal 040 to 176: printable codes
Then, you can use tr
to get only these characters:
然后,您可以使用tr
来仅获取以下字符:
cat input.txt | tr -cd '11121540-176' > output.txt
Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。
翻译自: https://www.systutorials.com/filter-away-non-printable-ascii-characters-on-linux/
ascii 不可打印字符