Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Linux (Bash), there's a way to use a command as a parameter for another command, using back-ticks:

> echo ===== `time` =====

This would print:

===== The current time is: 12:22:34.68 =====

Is there a way to do this in cmd.exe on WIndows ?

share|improve this question
1  
see this post –  Prince John Wesley May 27 '11 at 9:38
2  
    
Also see this this post (use of doskey command from cmd) –  misterjaytee May 27 '11 at 11:00
    
@misterjaytee: Command substitution and aliases are different things. –  grawity May 27 '11 at 13:59
    
@grawity - Thanks for pointing that out - Note to self: must read the question properly before responding... –  misterjaytee May 30 '11 at 13:26

1 Answer 1

up vote 1 down vote accepted

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 /?
share|improve this answer
    
Yep, for /f is what I was looking for. Thanks! On a side note: It's so kludgy and hard to remember (compared to the bash way). I should give up "bat programming" and learn something more productive - PowerShell maybe? –  Cristi Diaconescu Jul 7 '11 at 20:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.