Home Unix How is conditional execution used in UNIX? Conditional execution can be accomplished in UNIX with the use of control operators “and” and “or”. The and operator is represented as && and the syntax of their usage is : command1 && command2 This implies that the command 2 will only be executed if the command 1 returns an exit status 0.The or operator is represented by ||. The syntax of using the or operator is: command1 || command2 This implies that command2 is executed if the command 1 returns a non-zero exit value.Both the operators can be used together.For ex. command1 && command2 if exist status is zero || command3 if exit status is non-zero This implies that command 2 will be executed if and only if command 1 executes or else command 3 will be executed.
Post a Comment