1

In Linux use use AND Operators and it is represented by (&). In commands we can either use (&&) or (;). So, does a semi Colon (;) is also called an AND Operator?

1 Answers1

5

No, a semicolon is not a boolean operator. It is however, just like &&, &, and newlines, a command terminator, marking the end of a command.

The difference between

cmd1; cmd2

and

cmd1 && cmd2

is that in the first case, cmd2 will always execute after cmd1 has terminated, while in the second case, cmd2 only executes if cmd1 terminated with a zero exit status (signalling "success").

With

cmd1 & cmd2

cmd1 is started as a background job (an asynchronous task), and cmd2 is started immediately after starting cmd1 (the two would run concurrently).

Both & and ; are called "list separators", separating lists of commands. In the POSIX shell grammar, they are called "separator operators".

Kusalananda
  • 333,661