Is there something like Command Substitution in Windows CLI?
Try this:
echo. ===== %time% =====
I know this may not be what you want, because you mentioned command substitution... So this may be it:
for /f "usebackq tokens=*" %i in (`date/t&time/t`) do echo. ===== %i =====
For more hints about the usage of usebackq
try this command:
for /?
In Windows the '( )' operator has a similar behavior as the Bash command substitution.
This Linux script:
my_linux_variable=$(ls)
my_alternate_linux_variable=`ls`
echo $my_linux_command=$(ls)
echo $my_alternate_linux_command=`ls`
gives a similar result as Windows PowerShell:
$my_windowsPS_variable = (dir)
$my_windowsPS_variable
and as Windows CMD:
set my_windowsCMD_variable=(dir)
%my_windowsCMD_variable%
No, but here is the workaround:
D:\>time /t
08:18 PM
D:\>time /t > time.tmp
D:\>set /p time=<time.tmp
D:\>echo == %time% ==
== 08:18 PM ==
See also: Batch equivalent of Bash backticks.