问题
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 toC
, 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 inGNU 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