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

Clash 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
command-line
add a comment |Â
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
command-line
add a comment |Â
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
command-line
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
command-line
edited 2 hours ago
asked 3 hours ago
yekanchi
203
203
add a comment |Â
add a comment |Â
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:
- To print the entire path, use
echo %path%. This will print all directories on a single line separated with semicolons (;) - To search / replace a string in a variable, use
%path:a=b%which will replace allacharacters withb echo.is the command to print a newline&is used to separate commands, e.g.echo line1&echo line2will print two lines- 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.
what is %% signs used for, can;t we tellecho 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=Helloand thenecho %greeting%. Confusingly,PATHhappens to be both a command and a variable, so typing the commandpath, orecho %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$PATHfor 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
 |Â
show 1 more comment
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:
- To print the entire path, use
echo %path%. This will print all directories on a single line separated with semicolons (;) - To search / replace a string in a variable, use
%path:a=b%which will replace allacharacters withb echo.is the command to print a newline&is used to separate commands, e.g.echo line1&echo line2will print two lines- 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.
what is %% signs used for, can;t we tellecho 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=Helloand thenecho %greeting%. Confusingly,PATHhappens to be both a command and a variable, so typing the commandpath, orecho %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$PATHfor 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
 |Â
show 1 more comment
up vote
3
down vote
accepted
That's an interesting solution that I've never seen before. Let me try to explain:
- To print the entire path, use
echo %path%. This will print all directories on a single line separated with semicolons (;) - To search / replace a string in a variable, use
%path:a=b%which will replace allacharacters withb echo.is the command to print a newline&is used to separate commands, e.g.echo line1&echo line2will print two lines- 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.
what is %% signs used for, can;t we tellecho 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=Helloand thenecho %greeting%. Confusingly,PATHhappens to be both a command and a variable, so typing the commandpath, orecho %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$PATHfor 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
 |Â
show 1 more comment
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:
- To print the entire path, use
echo %path%. This will print all directories on a single line separated with semicolons (;) - To search / replace a string in a variable, use
%path:a=b%which will replace allacharacters withb echo.is the command to print a newline&is used to separate commands, e.g.echo line1&echo line2will print two lines- 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.
That's an interesting solution that I've never seen before. Let me try to explain:
- To print the entire path, use
echo %path%. This will print all directories on a single line separated with semicolons (;) - To search / replace a string in a variable, use
%path:a=b%which will replace allacharacters withb echo.is the command to print a newline&is used to separate commands, e.g.echo line1&echo line2will print two lines- 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.
answered 2 hours ago
Berend
1,2431612
1,2431612
what is %% signs used for, can;t we tellecho 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=Helloand thenecho %greeting%. Confusingly,PATHhappens to be both a command and a variable, so typing the commandpath, orecho %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$PATHfor 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
 |Â
show 1 more comment
what is %% signs used for, can;t we tellecho 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=Helloand thenecho %greeting%. Confusingly,PATHhappens to be both a command and a variable, so typing the commandpath, orecho %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$PATHfor 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
 |Â
show 1 more comment
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
