What is piping in linux and why it is used?

In this following post, you will learn what is piping in linux and why it is used.

Using piping, the output of first command can be passed onto the input of second command and the output of second command can be passed to third command as a input, but one should be careful in choosing the order of the commands while using pipe “|”, if the order of commands changes, the output will also change.

In the below scenario, before without using pipe(|), can see many files are listed under /etc/ path,

Pipe with other commands:

But, if you use pipe “|” along with head or tail or grep command in general, you can filter the top 10 lines under /etc/ path as below. Here, the whole output of ls command is passed into head command by the shell instead of being printed to the screen. The head command takes this output from the ls command as input data, and the output of head is then printed to the screen.

Piping is a fundamental feature of the Linux command line, contributing to the flexibility and versatility of the operating system. Mastering piping can significantly improve your ability to perform complex tasks and data manipulations in a streamlined manner. 🌐

How do you feel about this post? Drop your comments below..