Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute multiple commands in a single line [duplicate]

Tags:

windows

cmd

I know Unix has the following command which can execute multiple commands in a single line, how can I do this in DOS?

command1 ; command2 ; command3 ... 
like image 957
zdd Avatar asked Dec 05 '12 08:12

zdd


People also ask

Can you run 2 command prompts at once?

Click Start, type cmd, and press Enter to open a command prompt window. In the Windows taskbar, right-click the command prompt window icon and select Command Prompt. A second command prompt window is opened.

How do you pipe multiple commands?

You can make it do so by using the pipe character '|'. Pipe is used to combine two or more commands, and in this, the output of one command acts as input to another command, and this command's output may act as input to the next command and so on.

Can you have multiple commands on a single line in Linux?

Linux allows you to enter multiple commands at one time. The only requirement is that you separate the commands with a semicolon. Running the combination of commands creates the directory and moves the file in one line.


1 Answers

Googling gives me this:


Command A & Command B

Execute Command A, then execute Command B (no evaluation of anything)


Command A | Command B

Execute Command A, and redirect all its output into the input of Command B


Command A && Command B

Execute Command A, evaluate the errorlevel after running and if the exit code (errorlevel) is 0, only then execute Command B


Command A || Command B

Execute Command A, evaluate the exit code of this command and if it's anything but 0, only then execute Command B


like image 72
SidR Avatar answered Sep 18 '22 05:09

SidR