Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

6.4. Performing more than one command

Executing the second command only if the first is successful

 

To do this you would type:

command1 && command2

command2 will be executed if command1 successfully completes (if command1 fails command2 won't be run). This is called a logical AND.

Executing the second command only if the first fails

 

To do this you would type:

command1 || command2

command2 will be executed if command1 does not successfully completes (if command1 is successful command2 won't be run). This is called a logical OR.

Executing commands sequentially

 

To execute command sequentially regardless of the success/failure of the previous you simply type:

command1; command2

command2 will execute once command1 has completed.

Tip More than two commands
 

You can continue to use ';' (semicolon) characters to do more and more commands on the one line.

 
 
  Published under the terms of the GNU General Public License Design by Interspire