Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com
huuphan.com. Powered by Blogger.

My blog about Open Source: Zimbra Mail Server,linux,bash script,centos,linux command...

Run Multiple Commands in Linux

In this tutorial, How to Run Multiple Commands in Linux at Once. You will executing multiple Linux commands at one.

On Linux, there are three ways to run multiple commands in terminal.

1. Using Logical OR (ll) operator


The syntax


command A || command B

if command A runs successfully, command B won't execute. Command B will only execute if command A fails

Example:

sudo find /tmp -name devopsroles.com || touch huuphan.com

The output terminal as below

2. Using the AND (&&) Operator


The syntax

command A && command B

Command A runs successfully, If command B not error.

Example:

mkdir /tmp/devopsroles && cd /tmp

The output terminal as below

3. Using the Semicolon(;) Operator


The syntax

command A ; command B
Command A and command B run executed sequentially 

The output terminal as below

post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com

This Blog is protected by DMCA.com