Site icon TechGit

Run Multiple Linux Commands at Once – Run Multiple Linux Commands in One Line

How to run multiple Linux commands at once or run multiple Linux commands in one line. Running multiple commands in a single line Linux is easy, learn how:

How to Run Multiple Linux Commands in One Line

There are 3 ways to run multiple commands in one line in Linux:

See below to learn the use in full details:

  1. Using ;

When you use ; no matter the first command (command 1) run successfully or not, always run the second command (command 2).

  1. Using &&

When you use && the second command (command 2) will run only when the first command (command 1) run successfully.

  1. Using ||

When you use || the only when the second command (command 2) will be executed only when the first command (command 1) fails to run.

Running more than 2 commands at once in one line

You can use ; to run multiple Linux commands in one line. Simply use semicolon (;) to add/combine multiple commands in single line. The following format can be used:

command 1; command 2; command 3

NOTE: The command 1 will run first, then command 2 will run and then the command 3 will run. The commands will run irrespective of whether the previous command has beene xecuted successfully or not.

Similarly you can use command 1 && command 2 && command 3.

Original Article

FacebookTwitterTumblrRedditLinkedInHacker NewsDiggBufferGoogle ClassroomThreadsXINGShare
Exit mobile version