A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

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!