set A=2 && echo %A%
This does not echo A as 2 in windows. Is there any way to do it?
A=2 ; echo $A
works in bash. I want a similar behavior on windows
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m sure there are many ways to do this, here are two of them:
setlocal ENABLEDELAYEDEXPANSION&set "foo=bar baz"&echo.!foo!&endlocalset "foo=bar baz"&for /F "tokens=1,* delims==" %%A in ('set foo') do if "%%~A"=="foo" echo.%%BEdit: Added check to “filter” set results for 2nd solution, thanks Johannes Rössel