Search code examples
dos

Is it possible to perform a mathematical calculation using a DOS echo, in a single line?


For example, can I do

echo 3 + 5

and get 8?

Is it possible to do calculations using the date?


Solution

  • You can use set /a to calculate a mathematical expression:

    set /a x=3+5
    echo %x%
    

    Edit: here's a one-liner:

    @for /f usebackq %i in (`set /a 3 + 5`) do @echo %i