When using tr -t
command, string1
should be truncated to the length of string2
, right?
tr -t abcdefghijklmn 123 # abc... = string1, 123 = string2
the cellar is the safest place # actual input
the 3ell1r is the s1fest pl13e # actual output
'to truncate' is another word for 'to shorten', right?tr
translates, according to the pattern, completely ignoring the -t
option. If I autocomplete to --truncate-set1
[to assure that I use the correct option] produces the same output.
Question: what am I doing wrong here?
I work in BASH, on a Debian based Distro.
UPDATE
Please note that this is a copy of a comment I made below
I thought tr -t
means: shorten string1 to the length of string2. I see that a
is translated to 1
, that b
would be translated to 2
and that c
is translated to 3
.
This has nothing to do with shortening. 'To truncate' seems to mean something different than I thought. [I'm no native speaker]
tr -t abcdefghijklmn 123
is equivalent oftr abc 123
.string1
" withSTDIN
.string1
(an argument; calledSET1
in GNU man page) is truncated, input is not.tr
as "sets" or "patterns" of characters and not strings. Those corresponding sets/related patterns are used in the translation of the input. So the-t
in your example means that the first set is now only 3 characters, and that's applied in the translation, which is why the exact same example without-t
does, in fact, produce different output.