Run Multiple Commands in Linux

In this tutorial, How to Run Multiple Commands in LinuxLinux 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

Conclusion

Running multiple commands in Linux can significantly enhance your efficiency by allowing you to execute several tasks in a single command line. This tutorial covered three primary methods: using the logical OR (||) operator, the AND (&&) operator, and the semicolon (;) operator. Each method has its specific use case, providing flexibility depending on your needs. Mastering these techniques can streamline your workflow and improve productivity in a Linux environment. thank you for reading the huuphan.com page!

Comments

Popular posts from this blog

zimbra some services are not running [Solve problem]

Bash script list all IP addresses connected to Server

How to install php7 on centos 6