ZX2Slow
ZX2Slow

Reputation: 23

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

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?

Upvotes: 2

Views: 1054

Answers (2)

Inian
Inian

Reputation: 85800

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

Upvotes: 7

User9102d82
User9102d82

Reputation: 1190

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.

Upvotes: -3

Related Questions