I have seen | and ; and & to be used to batch together multiple commands on Linux shell. What are the differences among them?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
'|'is called the pipe symbol, it is used to take the output from one command and “pipe” it to another one.e.g.,
takes the output of the
lscommand and provides it to thewc -lcommand which counts the number of lines. It is quite common to have several pipes in a row output at various stages.Here’s a page that talks about pipes.
The
'&'is used to put a command in the background so that it can run, while you are returned to the command prompt and can continue to issue other commands.This page has a short example of a pipe and the amperstand to put something in the background. This page talks about managing background commands. Finally, under
sh/bash(and possibly shells other thancsh/tcsh)'&'can be used to redirect stdout and stderr as @cdarke reminds us in a helpful comment below.Any decent Linux/Unix tutorial would give you more information on these two.
I haven’t seen the
,used with commands, though;can be used to group several commands.Also see @Bruno comment below for more information about using
&&to chain commands in bash.