I want to use tr
to do some rot13 transformation. I can beautifully understand this command:
tr A-Za-z N-ZA-Mn-za-m <<< "URYC ZR CYRNFR"
which output is HELP ME PLEASE
, but I can't figure out how this other command can produce the same rot13 transformation:
tr .............A-Z A-ZA-Z <<< "URYC ZR CYRNFR"
So I have two questions:
- What's the magic behind the second
tr
command? - How to make the second command work for both lower and upper case, just like the first command?
Best Answer
It works as follows:
So
tr
will translateSET1
toSET2
.This is equivalent to first one because it is also shifting by
13
units as there 13 dots.To include the lower case letters, you'll have to arrange them in
SET1
with a similar offset, i.e.:That's 26 dots between
Z
anda
, spanning half the upper-case and half the lower-case alphabet. So thetr
command itself will be: