Tuesday, November 11, 2008

Command Line Tricks for Ubuntu Linux

Execute two or more commands sequentially

To execute two or more command sequentially regardless of the failure/success of the previous,
usage: $ command1; command2

command2 will execute after completing command1 .

Execute the second command only if the first command fails

usage: $ command1 || command2

command2 will be executed if command1 fails s (if command1 is successful command2 won't be run). logical OR operation.

Executing the second command only if the first is successful

usage: $ command1 && command2

command2 will be executed if command1 successfully completes (if command1 fails command2 won't be run). logical AND operation.

No comments: