Pipe in Linux

“Pipe” is a way to send the standard output of one command to another command in Linux-based operating systems. It is a way to forward the results of one command or program to another for further processing. On Linux, you may pipe a command’s output (stdout) into its input (stdin). The “|” character represents a pipe in Linux.

“Pipe” is a temporary connection between two or more computer programs, instructions, or processes. Linux uses command-line software called filters to do further processing by putting together a direct link between several processes, instructions, and programs. “Pipes” let you combine two or more commands and run them one after the other. You can use powerful commands that can do hard tasks quickly and easily.

Command

$ command 1 | command 2 | command 3 | … | command N

Example 1

  • The “Pipe” command will be used to connect the “ls” and “more” programs in this example. To see the directory and file listings in long format, use the “ls” command with the “-l” option. While the “more” button shows the list one screen at a time that can be scrolled.
ls -l | more
  • To see a complete list of folders and files, hit “Enter”.

Example 2

  • As many different applications as we desire can be piped together. To get the fourth and fifth  file, we piped the output to tail as seen below.
ls | head -6 | tail -2

Feedback

Do you want to provide us with feedback? Provide us with feedback directly at info@elearnbee.com.

Share us:

AD BLOCK 1