Conditional Execution

Syntax

An AND list of commands has the form

      command1  && command2

command2 is executed if, and only if, command1 succeeds.


A single & will always execute both commands
      command1 & command2


An OR list of commands has the form

      command1  || command2

command2 is executed if, and only if, command1 fails

Example

   COPY Z:\Oracle\TNSnames.ORA C:\Oracle\ || ECHO The Copy Failed

"Cooperation which needs consideration is a commercial contract, and not friendship. Conditional cooperation is like adulterated cement which does not bind" - Mohandas K. Gandhi

Related:

IF command



Back to the Top

Simon Sheppard
SS64.com