我有一个包含字符串的文件:
aa12bb34cc z23abZY
123 87aab
6667771
所以我希望输出是:
aabbcc ab aab
使用 tr 我获得了这个字符串作为输出:
aa bb cc ab aab
有什么想法吗?
最佳答案
我建议使用 GNU tr:
tr -cd 'abc ' < file
输出:
aabbcc ab aab
-d
: delete alla
,b
,c
and white spaces
-c
use the complement. Delete everything buta
,b
,c
and white spaces.
关于bash - 如何在bash中删除文件中除特定字符之外的所有内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41088117/