ascii 不可打印字符_在Linux上过滤掉不可打印的ASCII字符?

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 不可打印字符

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值