What does tr -d [=,=] do?

六眼飞鱼酱① 提交于 2019-12-12 21:24:25

问题


I have a code example and there seems to be a piece of extra formatting tacked onto the end of some text processing:

tr -d [=,=]

I don't know what this does and the man page for tr is of little help. Any insight on what this does?


回答1:


From the man tr page,

[=equiv=]

Equivalence classes

The syntax [=C=] expands to all of the characters that are equivalent to C, in no particular order. Equivalence classes are a relatively recent invention intended to support non-English alphabets. But there seems to be no standard way to define them or determine their contents. Therefore, they are not fully implemented in GNU tr; each character's equivalence class consists only of that character, which is of no particular use.

An example from the POSIX tr page

This example uses an equivalence class to identify accented variants of the base character 'e' in file1, which are stripped of diacritical marks (WikiLink) and written to file2.

tr "[=e=]" "[e*]" <file1 >file2

i.e. if in file1 if e is represented as accented (either a é or è), they are treated as normal e




回答2:


It will just remove the comma between the ==. check below output.

%_Host@User> echo "1==,==2==,==3=,=4=,=5" | tr -d [=,=]
1====2====3==4==5
%_Host@User>

thanks.



来源:https://stackoverflow.com/questions/42303902/what-does-tr-d-do

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!