May 12, 2017

Difference between | and ; while typing commands on prompt


When I started learning Linux from EDX courses, | (pipeline) is the first few things that are taught to me. From what I understand, pipeline allows subsequent commands to be executed co-currently with the previous commands (i.e., commands before the pipeline).

Much later, I am taught to use ; (semi-colon) as a means to "combine several commands and statements and even conditionally execute them based on the behavior of operators used in between them. This method is called chaining of commands." Does this mean that semi-colon allows subsequent execution of commands provided that the previous one is already completed?

My questions are - (1) What is the major difference between '|' and ';', and (2) when should we use either of the characters? Can both of them be used together in the same chain of commands?

Click Here!