What do the dots in this tr command do: tr …A-Z A-ZA-Z <<< “JVPQBOV” (with 13 dots)what is the benefit of --squeeze-repeats in tr commandWhy can't tr read from /dev/urandom on OSX?broken pipe error with popen and JS ffiIs the historical Unix V5 tr command padding behavior of set2 different from what we consider today “classic” System V (1983-1988) behavior?Heirloom Toolchest tr: error(s) trying to delete the complement of a set containing a multibyte character?how to substitute minus sign with trPulling IP address from ping command with sed?Why does tr -sc 'A-Za-z' '[12*]' includes empty line?I cannot understand what -c parameter does in tr command in Ubuntu GNU/Linux even though I read the manualStrange behaviour of tr using ranges

Important Resources for Dark Age Civilizations?

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

What are these boxed doors outside store fronts in New York?

Can I ask the recruiters in my resume to put the reason why I am rejected?

Does detail obscure or enhance action?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

Alternative to sending password over mail?

What does it mean to describe someone as a butt steak?

How do I draw and define two right triangles next to each other?

Arrow those variables!

What's the point of deactivating Num Lock on login screens?

Find the result of this dual key cipher

Theorems that impeded progress

Is it unprofessional to ask if a job posting on GlassDoor is real?

NMaximize is not converging to a solution

Today is the Center

Do infinite dimensional systems make sense?

Intersection point of 2 lines defined by 2 points each

Fully-Firstable Anagram Sets

Why does Kotter return in Welcome Back Kotter?

What does the "remote control" for a QF-4 look like?

Is it legal for company to use my work email to pretend I still work there?

Has there ever been an airliner design involving reducing generator load by installing solar panels?

Paid for article while in US on F-1 visa?



What do the dots in this tr command do: tr …A-Z A-ZA-Z


what is the benefit of --squeeze-repeats in tr commandWhy can't tr read from /dev/urandom on OSX?broken pipe error with popen and JS ffiIs the historical Unix V5 tr command padding behavior of set2 different from what we consider today “classic” System V (1983-1988) behavior?Heirloom Toolchest tr: error(s) trying to delete the complement of a set containing a multibyte character?how to substitute minus sign with trPulling IP address from ping command with sed?Why does tr -sc 'A-Za-z' '[12*]' includes empty line?I cannot understand what -c parameter does in tr command in Ubuntu GNU/Linux even though I read the manualStrange behaviour of tr using ranges






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















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:



  1. What's the magic behind the second tr command?

  2. How to make the second command work for both lower and upper case, just like the first command?









share|improve this question









New contributor




Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • (count the dots)

    – Michael Homer
    3 hours ago











  • I know there's 13 dots. What I wanna know is how it works. There's no explanation about dots in the manual

    – Frederico Oliveira
    3 hours ago






  • 1





    you had better hope you don't run into a dot in your input text

    – iruvar
    2 hours ago

















5















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:



  1. What's the magic behind the second tr command?

  2. How to make the second command work for both lower and upper case, just like the first command?









share|improve this question









New contributor




Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • (count the dots)

    – Michael Homer
    3 hours ago











  • I know there's 13 dots. What I wanna know is how it works. There's no explanation about dots in the manual

    – Frederico Oliveira
    3 hours ago






  • 1





    you had better hope you don't run into a dot in your input text

    – iruvar
    2 hours ago













5












5








5








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:



  1. What's the magic behind the second tr command?

  2. How to make the second command work for both lower and upper case, just like the first command?









share|improve this question









New contributor




Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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:



  1. What's the magic behind the second tr command?

  2. How to make the second command work for both lower and upper case, just like the first command?






tr






share|improve this question









New contributor




Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 3 hours ago









Michael Homer

50.6k8140177




50.6k8140177






New contributor




Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









Frederico OliveiraFrederico Oliveira

242




242




New contributor




Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • (count the dots)

    – Michael Homer
    3 hours ago











  • I know there's 13 dots. What I wanna know is how it works. There's no explanation about dots in the manual

    – Frederico Oliveira
    3 hours ago






  • 1





    you had better hope you don't run into a dot in your input text

    – iruvar
    2 hours ago

















  • (count the dots)

    – Michael Homer
    3 hours ago











  • I know there's 13 dots. What I wanna know is how it works. There's no explanation about dots in the manual

    – Frederico Oliveira
    3 hours ago






  • 1





    you had better hope you don't run into a dot in your input text

    – iruvar
    2 hours ago
















(count the dots)

– Michael Homer
3 hours ago





(count the dots)

– Michael Homer
3 hours ago













I know there's 13 dots. What I wanna know is how it works. There's no explanation about dots in the manual

– Frederico Oliveira
3 hours ago





I know there's 13 dots. What I wanna know is how it works. There's no explanation about dots in the manual

– Frederico Oliveira
3 hours ago




1




1





you had better hope you don't run into a dot in your input text

– iruvar
2 hours ago





you had better hope you don't run into a dot in your input text

– iruvar
2 hours ago










2 Answers
2






active

oldest

votes


















4














It works as follows:



SET1-> .............ABCDEFGHIJKLMNOPQRSTUVWXYZ
SET2-> ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM


So tr will translate SET1 to SET2.



This is equivalent to first one because it is also shifting by 13 units as there 13 dots.






share|improve this answer






























    -1














    Ok, so thanks to @Prvt_Yadv I was able to understand the dots. Here's the first question answer:




    What's the magic behind the second tr command?




    The dots are replaced by a sequence of letters starting from a to the number of dots. So



    tr .............A-Z A-ZA-Z will translate to tr A-MA-Z A-ZA-Z



    In this case the sets are:



    SET1 -> ABCDEFGHIJKLMABCDEFGHIJKLMNOPQRSTUVXWYZ
    SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


    But since the beginning of both sets are identical until letter M, this part is discarded becoming then



    SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
    SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


    But since the first set already contains all 26 letters and set2 has repeating trailing letter, those are discarded too, finally becoming



    SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
    SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLM


    Which is the rot13 substitution and identical to the first command (except for not dealing with lower cases here). The same logic can be applied for the title of the question:



    tr ...A-Z A-ZA-Z <<< “JVPQBOV” would become tr A-CA-Z A-ZA-Z <<< “JVPQBOV”



    The sets being:



    SET1 -> ABCABCDEFGHIJKLMNOPQRSTUVXWYZ
    SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


    Discarding the initial identical sequence and the trailing repeating letters they become:



    SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
    SET2 -> DEFGHIJKLMNOPQRSTUVXWYZABC


    Which is the rot3 substitution.



    Now for the second question:




    How to make the second command work for both lower and upper case, just like the first command?




    The dots are substituted by a sequence of letter of the same case as the next sequence. That means that tr .....A-Z will translate to tr A-EA-Z whereas tr .....a-z will translate to tr a-ea-z. But the dots only work before the literal sequence, not after. So the immediate solution idea tr .....A-Z.....a-z won't work, because it will not translate to tr A-EA-Za-ea-z. The only reliable way to make it work is to use two tr commands as follow



    tr .............A-Z A-ZA-Z <<< "ABJ V hqrefgnaq" | tr .............a-z a-za-z


    Now it works for both upper and lower case :)



    A caveat to using the dots substitution was gave by @iruvar: this command will not work as expected when the input stings has dots. So the following command won't print T.h.a.n.k.s.



    tr .............A-Z A-ZA-Z <<< "G.u.n.a.x.f." | tr .............a-z a-za-z


    It will print TMhMaMnMkMsM instead, substituting the dots to M






    share|improve this answer










    New contributor




    Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




















    • I'm not sure how you concluded that "dots are replaced by a sequence of letters starting from a to the number of dots"; that's not at all the case. There's no magic involved; as Prvt_Yadv explained, there are two sets and tr is mapping from set 1 to set 2, as always, but in this case you've mapped the character . to A, and also B, and also ..., and also M. This doesn't matter since your input doesn't contain a ., but if it did it would turn into an M (tr uses the last output you specify for a given input)

      – Michael Mrozek
      4 mins ago











    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Frederico Oliveira is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f510838%2fwhat-do-the-dots-in-this-tr-command-do-tr-a-z-a-za-z-jvpqbov%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    It works as follows:



    SET1-> .............ABCDEFGHIJKLMNOPQRSTUVWXYZ
    SET2-> ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM


    So tr will translate SET1 to SET2.



    This is equivalent to first one because it is also shifting by 13 units as there 13 dots.






    share|improve this answer



























      4














      It works as follows:



      SET1-> .............ABCDEFGHIJKLMNOPQRSTUVWXYZ
      SET2-> ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM


      So tr will translate SET1 to SET2.



      This is equivalent to first one because it is also shifting by 13 units as there 13 dots.






      share|improve this answer

























        4












        4








        4







        It works as follows:



        SET1-> .............ABCDEFGHIJKLMNOPQRSTUVWXYZ
        SET2-> ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM


        So tr will translate SET1 to SET2.



        This is equivalent to first one because it is also shifting by 13 units as there 13 dots.






        share|improve this answer













        It works as follows:



        SET1-> .............ABCDEFGHIJKLMNOPQRSTUVWXYZ
        SET2-> ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM


        So tr will translate SET1 to SET2.



        This is equivalent to first one because it is also shifting by 13 units as there 13 dots.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 3 hours ago









        Prvt_YadvPrvt_Yadv

        3,09631329




        3,09631329























            -1














            Ok, so thanks to @Prvt_Yadv I was able to understand the dots. Here's the first question answer:




            What's the magic behind the second tr command?




            The dots are replaced by a sequence of letters starting from a to the number of dots. So



            tr .............A-Z A-ZA-Z will translate to tr A-MA-Z A-ZA-Z



            In this case the sets are:



            SET1 -> ABCDEFGHIJKLMABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            But since the beginning of both sets are identical until letter M, this part is discarded becoming then



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            But since the first set already contains all 26 letters and set2 has repeating trailing letter, those are discarded too, finally becoming



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLM


            Which is the rot13 substitution and identical to the first command (except for not dealing with lower cases here). The same logic can be applied for the title of the question:



            tr ...A-Z A-ZA-Z <<< “JVPQBOV” would become tr A-CA-Z A-ZA-Z <<< “JVPQBOV”



            The sets being:



            SET1 -> ABCABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            Discarding the initial identical sequence and the trailing repeating letters they become:



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> DEFGHIJKLMNOPQRSTUVXWYZABC


            Which is the rot3 substitution.



            Now for the second question:




            How to make the second command work for both lower and upper case, just like the first command?




            The dots are substituted by a sequence of letter of the same case as the next sequence. That means that tr .....A-Z will translate to tr A-EA-Z whereas tr .....a-z will translate to tr a-ea-z. But the dots only work before the literal sequence, not after. So the immediate solution idea tr .....A-Z.....a-z won't work, because it will not translate to tr A-EA-Za-ea-z. The only reliable way to make it work is to use two tr commands as follow



            tr .............A-Z A-ZA-Z <<< "ABJ V hqrefgnaq" | tr .............a-z a-za-z


            Now it works for both upper and lower case :)



            A caveat to using the dots substitution was gave by @iruvar: this command will not work as expected when the input stings has dots. So the following command won't print T.h.a.n.k.s.



            tr .............A-Z A-ZA-Z <<< "G.u.n.a.x.f." | tr .............a-z a-za-z


            It will print TMhMaMnMkMsM instead, substituting the dots to M






            share|improve this answer










            New contributor




            Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




















            • I'm not sure how you concluded that "dots are replaced by a sequence of letters starting from a to the number of dots"; that's not at all the case. There's no magic involved; as Prvt_Yadv explained, there are two sets and tr is mapping from set 1 to set 2, as always, but in this case you've mapped the character . to A, and also B, and also ..., and also M. This doesn't matter since your input doesn't contain a ., but if it did it would turn into an M (tr uses the last output you specify for a given input)

              – Michael Mrozek
              4 mins ago















            -1














            Ok, so thanks to @Prvt_Yadv I was able to understand the dots. Here's the first question answer:




            What's the magic behind the second tr command?




            The dots are replaced by a sequence of letters starting from a to the number of dots. So



            tr .............A-Z A-ZA-Z will translate to tr A-MA-Z A-ZA-Z



            In this case the sets are:



            SET1 -> ABCDEFGHIJKLMABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            But since the beginning of both sets are identical until letter M, this part is discarded becoming then



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            But since the first set already contains all 26 letters and set2 has repeating trailing letter, those are discarded too, finally becoming



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLM


            Which is the rot13 substitution and identical to the first command (except for not dealing with lower cases here). The same logic can be applied for the title of the question:



            tr ...A-Z A-ZA-Z <<< “JVPQBOV” would become tr A-CA-Z A-ZA-Z <<< “JVPQBOV”



            The sets being:



            SET1 -> ABCABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            Discarding the initial identical sequence and the trailing repeating letters they become:



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> DEFGHIJKLMNOPQRSTUVXWYZABC


            Which is the rot3 substitution.



            Now for the second question:




            How to make the second command work for both lower and upper case, just like the first command?




            The dots are substituted by a sequence of letter of the same case as the next sequence. That means that tr .....A-Z will translate to tr A-EA-Z whereas tr .....a-z will translate to tr a-ea-z. But the dots only work before the literal sequence, not after. So the immediate solution idea tr .....A-Z.....a-z won't work, because it will not translate to tr A-EA-Za-ea-z. The only reliable way to make it work is to use two tr commands as follow



            tr .............A-Z A-ZA-Z <<< "ABJ V hqrefgnaq" | tr .............a-z a-za-z


            Now it works for both upper and lower case :)



            A caveat to using the dots substitution was gave by @iruvar: this command will not work as expected when the input stings has dots. So the following command won't print T.h.a.n.k.s.



            tr .............A-Z A-ZA-Z <<< "G.u.n.a.x.f." | tr .............a-z a-za-z


            It will print TMhMaMnMkMsM instead, substituting the dots to M






            share|improve this answer










            New contributor




            Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




















            • I'm not sure how you concluded that "dots are replaced by a sequence of letters starting from a to the number of dots"; that's not at all the case. There's no magic involved; as Prvt_Yadv explained, there are two sets and tr is mapping from set 1 to set 2, as always, but in this case you've mapped the character . to A, and also B, and also ..., and also M. This doesn't matter since your input doesn't contain a ., but if it did it would turn into an M (tr uses the last output you specify for a given input)

              – Michael Mrozek
              4 mins ago













            -1












            -1








            -1







            Ok, so thanks to @Prvt_Yadv I was able to understand the dots. Here's the first question answer:




            What's the magic behind the second tr command?




            The dots are replaced by a sequence of letters starting from a to the number of dots. So



            tr .............A-Z A-ZA-Z will translate to tr A-MA-Z A-ZA-Z



            In this case the sets are:



            SET1 -> ABCDEFGHIJKLMABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            But since the beginning of both sets are identical until letter M, this part is discarded becoming then



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            But since the first set already contains all 26 letters and set2 has repeating trailing letter, those are discarded too, finally becoming



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLM


            Which is the rot13 substitution and identical to the first command (except for not dealing with lower cases here). The same logic can be applied for the title of the question:



            tr ...A-Z A-ZA-Z <<< “JVPQBOV” would become tr A-CA-Z A-ZA-Z <<< “JVPQBOV”



            The sets being:



            SET1 -> ABCABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            Discarding the initial identical sequence and the trailing repeating letters they become:



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> DEFGHIJKLMNOPQRSTUVXWYZABC


            Which is the rot3 substitution.



            Now for the second question:




            How to make the second command work for both lower and upper case, just like the first command?




            The dots are substituted by a sequence of letter of the same case as the next sequence. That means that tr .....A-Z will translate to tr A-EA-Z whereas tr .....a-z will translate to tr a-ea-z. But the dots only work before the literal sequence, not after. So the immediate solution idea tr .....A-Z.....a-z won't work, because it will not translate to tr A-EA-Za-ea-z. The only reliable way to make it work is to use two tr commands as follow



            tr .............A-Z A-ZA-Z <<< "ABJ V hqrefgnaq" | tr .............a-z a-za-z


            Now it works for both upper and lower case :)



            A caveat to using the dots substitution was gave by @iruvar: this command will not work as expected when the input stings has dots. So the following command won't print T.h.a.n.k.s.



            tr .............A-Z A-ZA-Z <<< "G.u.n.a.x.f." | tr .............a-z a-za-z


            It will print TMhMaMnMkMsM instead, substituting the dots to M






            share|improve this answer










            New contributor




            Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.










            Ok, so thanks to @Prvt_Yadv I was able to understand the dots. Here's the first question answer:




            What's the magic behind the second tr command?




            The dots are replaced by a sequence of letters starting from a to the number of dots. So



            tr .............A-Z A-ZA-Z will translate to tr A-MA-Z A-ZA-Z



            In this case the sets are:



            SET1 -> ABCDEFGHIJKLMABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            But since the beginning of both sets are identical until letter M, this part is discarded becoming then



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            But since the first set already contains all 26 letters and set2 has repeating trailing letter, those are discarded too, finally becoming



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> NOPQRSTUVXWYZABCDEFGHIJKLM


            Which is the rot13 substitution and identical to the first command (except for not dealing with lower cases here). The same logic can be applied for the title of the question:



            tr ...A-Z A-ZA-Z <<< “JVPQBOV” would become tr A-CA-Z A-ZA-Z <<< “JVPQBOV”



            The sets being:



            SET1 -> ABCABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> ABCDEFGHIJKLMNOPQRSTUVXWYZABCDEFGHIJKLMNOPQRSTUVXWYZ


            Discarding the initial identical sequence and the trailing repeating letters they become:



            SET1 -> ABCDEFGHIJKLMNOPQRSTUVXWYZ
            SET2 -> DEFGHIJKLMNOPQRSTUVXWYZABC


            Which is the rot3 substitution.



            Now for the second question:




            How to make the second command work for both lower and upper case, just like the first command?




            The dots are substituted by a sequence of letter of the same case as the next sequence. That means that tr .....A-Z will translate to tr A-EA-Z whereas tr .....a-z will translate to tr a-ea-z. But the dots only work before the literal sequence, not after. So the immediate solution idea tr .....A-Z.....a-z won't work, because it will not translate to tr A-EA-Za-ea-z. The only reliable way to make it work is to use two tr commands as follow



            tr .............A-Z A-ZA-Z <<< "ABJ V hqrefgnaq" | tr .............a-z a-za-z


            Now it works for both upper and lower case :)



            A caveat to using the dots substitution was gave by @iruvar: this command will not work as expected when the input stings has dots. So the following command won't print T.h.a.n.k.s.



            tr .............A-Z A-ZA-Z <<< "G.u.n.a.x.f." | tr .............a-z a-za-z


            It will print TMhMaMnMkMsM instead, substituting the dots to M







            share|improve this answer










            New contributor




            Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            share|improve this answer



            share|improve this answer








            edited 1 hour ago





















            New contributor




            Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            answered 1 hour ago









            Frederico OliveiraFrederico Oliveira

            242




            242




            New contributor




            Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





            New contributor





            Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            Frederico Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.












            • I'm not sure how you concluded that "dots are replaced by a sequence of letters starting from a to the number of dots"; that's not at all the case. There's no magic involved; as Prvt_Yadv explained, there are two sets and tr is mapping from set 1 to set 2, as always, but in this case you've mapped the character . to A, and also B, and also ..., and also M. This doesn't matter since your input doesn't contain a ., but if it did it would turn into an M (tr uses the last output you specify for a given input)

              – Michael Mrozek
              4 mins ago

















            • I'm not sure how you concluded that "dots are replaced by a sequence of letters starting from a to the number of dots"; that's not at all the case. There's no magic involved; as Prvt_Yadv explained, there are two sets and tr is mapping from set 1 to set 2, as always, but in this case you've mapped the character . to A, and also B, and also ..., and also M. This doesn't matter since your input doesn't contain a ., but if it did it would turn into an M (tr uses the last output you specify for a given input)

              – Michael Mrozek
              4 mins ago
















            I'm not sure how you concluded that "dots are replaced by a sequence of letters starting from a to the number of dots"; that's not at all the case. There's no magic involved; as Prvt_Yadv explained, there are two sets and tr is mapping from set 1 to set 2, as always, but in this case you've mapped the character . to A, and also B, and also ..., and also M. This doesn't matter since your input doesn't contain a ., but if it did it would turn into an M (tr uses the last output you specify for a given input)

            – Michael Mrozek
            4 mins ago





            I'm not sure how you concluded that "dots are replaced by a sequence of letters starting from a to the number of dots"; that's not at all the case. There's no magic involved; as Prvt_Yadv explained, there are two sets and tr is mapping from set 1 to set 2, as always, but in this case you've mapped the character . to A, and also B, and also ..., and also M. This doesn't matter since your input doesn't contain a ., but if it did it would turn into an M (tr uses the last output you specify for a given input)

            – Michael Mrozek
            4 mins ago










            Frederico Oliveira is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Frederico Oliveira is a new contributor. Be nice, and check out our Code of Conduct.












            Frederico Oliveira is a new contributor. Be nice, and check out our Code of Conduct.











            Frederico Oliveira is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f510838%2fwhat-do-the-dots-in-this-tr-command-do-tr-a-z-a-za-z-jvpqbov%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

            Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

            Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar