Windows Command Shell: Store the output of another command in a variable.

How often had i to look up this in the web, always wondering about myself still using the Windows-CMD-shell… Should move on to powershell…

store the output of another command in a variable

  • Example: the „date“-command
  • c:\RH\>date /T
  • Copy the date into the variable „TTT“
  • c:\RH\>for /f %D in ('date /T 2^> nul') do @(set TTT=%D)
    c:\RH\>echo %TTT%

Not elegant, not intuitive, not self-explanatory: This Shell Scripting language seems not to be made for daily usage 😉

Schreibe einen Kommentar