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
    30.10.2018
    
  • 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%
    30.10.2018
    

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

Schreibe einen Kommentar