How this windows command works: echo %path:;=&echo.%

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












Seeking to find a solution to print out path parameters of the windows CMD i came to this solution. the answer is this commad:



echo %path:;=&echo.%


now i wonder how this command works










share|improve this question



























    up vote
    3
    down vote

    favorite












    Seeking to find a solution to print out path parameters of the windows CMD i came to this solution. the answer is this commad:



    echo %path:;=&echo.%


    now i wonder how this command works










    share|improve this question

























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      Seeking to find a solution to print out path parameters of the windows CMD i came to this solution. the answer is this commad:



      echo %path:;=&echo.%


      now i wonder how this command works










      share|improve this question















      Seeking to find a solution to print out path parameters of the windows CMD i came to this solution. the answer is this commad:



      echo %path:;=&echo.%


      now i wonder how this command works







      command-line






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago

























      asked 3 hours ago









      yekanchi

      203




      203




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          That's an interesting solution that I've never seen before. Let me try to explain:



          1. To print the entire path, use echo %path%. This will print all directories on a single line separated with semicolons (;)

          2. To search / replace a string in a variable, use %path:a=b% which will replace all a characters with b


          3. echo. is the command to print a newline


          4. & is used to separate commands, e.g. echo line1&echo line2 will print two lines

          5. In effect, semicolons in the path are replaced with a command to print a newline. Or maybe it is interpreted as 'replace ; with nothing, and then, print a newline'. I can't find any documentation on this, so it's just my interpretation. Frankly, I didn't even know that was possible, but there you go.





          share|improve this answer




















          • what is %% signs used for, can;t we tell echo path? are %% used for variables?
            – yekanchi
            2 hours ago






          • 1




            Yes, that is correct, those are used to get the value of a variable. For instance: set greeting=Hello and then echo %greeting%. Confusingly, PATH happens to be both a command and a variable, so typing the command path, or echo %path% will have the same result.
            – Berend
            2 hours ago











          • what this syntax is called? is it regex? or something used in windows CMD only
            – yekanchi
            2 hours ago










          • I'm not sure if there's a name for this, it is just the way variables work in DOS. Other languages, such as bash, use $PATH for instance.
            – Berend
            2 hours ago










          • This is not regex, its cmd only. That's why I removed the regex tag from the question. The correct naming would be Command Line Syntax.
            – LPChip
            2 hours ago











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "3"
          ;
          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',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1369142%2fhow-this-windows-command-works-echo-path-echo%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          That's an interesting solution that I've never seen before. Let me try to explain:



          1. To print the entire path, use echo %path%. This will print all directories on a single line separated with semicolons (;)

          2. To search / replace a string in a variable, use %path:a=b% which will replace all a characters with b


          3. echo. is the command to print a newline


          4. & is used to separate commands, e.g. echo line1&echo line2 will print two lines

          5. In effect, semicolons in the path are replaced with a command to print a newline. Or maybe it is interpreted as 'replace ; with nothing, and then, print a newline'. I can't find any documentation on this, so it's just my interpretation. Frankly, I didn't even know that was possible, but there you go.





          share|improve this answer




















          • what is %% signs used for, can;t we tell echo path? are %% used for variables?
            – yekanchi
            2 hours ago






          • 1




            Yes, that is correct, those are used to get the value of a variable. For instance: set greeting=Hello and then echo %greeting%. Confusingly, PATH happens to be both a command and a variable, so typing the command path, or echo %path% will have the same result.
            – Berend
            2 hours ago











          • what this syntax is called? is it regex? or something used in windows CMD only
            – yekanchi
            2 hours ago










          • I'm not sure if there's a name for this, it is just the way variables work in DOS. Other languages, such as bash, use $PATH for instance.
            – Berend
            2 hours ago










          • This is not regex, its cmd only. That's why I removed the regex tag from the question. The correct naming would be Command Line Syntax.
            – LPChip
            2 hours ago















          up vote
          3
          down vote



          accepted










          That's an interesting solution that I've never seen before. Let me try to explain:



          1. To print the entire path, use echo %path%. This will print all directories on a single line separated with semicolons (;)

          2. To search / replace a string in a variable, use %path:a=b% which will replace all a characters with b


          3. echo. is the command to print a newline


          4. & is used to separate commands, e.g. echo line1&echo line2 will print two lines

          5. In effect, semicolons in the path are replaced with a command to print a newline. Or maybe it is interpreted as 'replace ; with nothing, and then, print a newline'. I can't find any documentation on this, so it's just my interpretation. Frankly, I didn't even know that was possible, but there you go.





          share|improve this answer




















          • what is %% signs used for, can;t we tell echo path? are %% used for variables?
            – yekanchi
            2 hours ago






          • 1




            Yes, that is correct, those are used to get the value of a variable. For instance: set greeting=Hello and then echo %greeting%. Confusingly, PATH happens to be both a command and a variable, so typing the command path, or echo %path% will have the same result.
            – Berend
            2 hours ago











          • what this syntax is called? is it regex? or something used in windows CMD only
            – yekanchi
            2 hours ago










          • I'm not sure if there's a name for this, it is just the way variables work in DOS. Other languages, such as bash, use $PATH for instance.
            – Berend
            2 hours ago










          • This is not regex, its cmd only. That's why I removed the regex tag from the question. The correct naming would be Command Line Syntax.
            – LPChip
            2 hours ago













          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          That's an interesting solution that I've never seen before. Let me try to explain:



          1. To print the entire path, use echo %path%. This will print all directories on a single line separated with semicolons (;)

          2. To search / replace a string in a variable, use %path:a=b% which will replace all a characters with b


          3. echo. is the command to print a newline


          4. & is used to separate commands, e.g. echo line1&echo line2 will print two lines

          5. In effect, semicolons in the path are replaced with a command to print a newline. Or maybe it is interpreted as 'replace ; with nothing, and then, print a newline'. I can't find any documentation on this, so it's just my interpretation. Frankly, I didn't even know that was possible, but there you go.





          share|improve this answer












          That's an interesting solution that I've never seen before. Let me try to explain:



          1. To print the entire path, use echo %path%. This will print all directories on a single line separated with semicolons (;)

          2. To search / replace a string in a variable, use %path:a=b% which will replace all a characters with b


          3. echo. is the command to print a newline


          4. & is used to separate commands, e.g. echo line1&echo line2 will print two lines

          5. In effect, semicolons in the path are replaced with a command to print a newline. Or maybe it is interpreted as 'replace ; with nothing, and then, print a newline'. I can't find any documentation on this, so it's just my interpretation. Frankly, I didn't even know that was possible, but there you go.






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 hours ago









          Berend

          1,2431612




          1,2431612











          • what is %% signs used for, can;t we tell echo path? are %% used for variables?
            – yekanchi
            2 hours ago






          • 1




            Yes, that is correct, those are used to get the value of a variable. For instance: set greeting=Hello and then echo %greeting%. Confusingly, PATH happens to be both a command and a variable, so typing the command path, or echo %path% will have the same result.
            – Berend
            2 hours ago











          • what this syntax is called? is it regex? or something used in windows CMD only
            – yekanchi
            2 hours ago










          • I'm not sure if there's a name for this, it is just the way variables work in DOS. Other languages, such as bash, use $PATH for instance.
            – Berend
            2 hours ago










          • This is not regex, its cmd only. That's why I removed the regex tag from the question. The correct naming would be Command Line Syntax.
            – LPChip
            2 hours ago

















          • what is %% signs used for, can;t we tell echo path? are %% used for variables?
            – yekanchi
            2 hours ago






          • 1




            Yes, that is correct, those are used to get the value of a variable. For instance: set greeting=Hello and then echo %greeting%. Confusingly, PATH happens to be both a command and a variable, so typing the command path, or echo %path% will have the same result.
            – Berend
            2 hours ago











          • what this syntax is called? is it regex? or something used in windows CMD only
            – yekanchi
            2 hours ago










          • I'm not sure if there's a name for this, it is just the way variables work in DOS. Other languages, such as bash, use $PATH for instance.
            – Berend
            2 hours ago










          • This is not regex, its cmd only. That's why I removed the regex tag from the question. The correct naming would be Command Line Syntax.
            – LPChip
            2 hours ago
















          what is %% signs used for, can;t we tell echo path? are %% used for variables?
          – yekanchi
          2 hours ago




          what is %% signs used for, can;t we tell echo path? are %% used for variables?
          – yekanchi
          2 hours ago




          1




          1




          Yes, that is correct, those are used to get the value of a variable. For instance: set greeting=Hello and then echo %greeting%. Confusingly, PATH happens to be both a command and a variable, so typing the command path, or echo %path% will have the same result.
          – Berend
          2 hours ago





          Yes, that is correct, those are used to get the value of a variable. For instance: set greeting=Hello and then echo %greeting%. Confusingly, PATH happens to be both a command and a variable, so typing the command path, or echo %path% will have the same result.
          – Berend
          2 hours ago













          what this syntax is called? is it regex? or something used in windows CMD only
          – yekanchi
          2 hours ago




          what this syntax is called? is it regex? or something used in windows CMD only
          – yekanchi
          2 hours ago












          I'm not sure if there's a name for this, it is just the way variables work in DOS. Other languages, such as bash, use $PATH for instance.
          – Berend
          2 hours ago




          I'm not sure if there's a name for this, it is just the way variables work in DOS. Other languages, such as bash, use $PATH for instance.
          – Berend
          2 hours ago












          This is not regex, its cmd only. That's why I removed the regex tag from the question. The correct naming would be Command Line Syntax.
          – LPChip
          2 hours ago





          This is not regex, its cmd only. That's why I removed the regex tag from the question. The correct naming would be Command Line Syntax.
          – LPChip
          2 hours ago


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1369142%2fhow-this-windows-command-works-echo-path-echo%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          White Anglo-Saxon Protestant

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          One-line joke