Youll be familiar with the concept of a pipe in the real world.
It is a construction that redirects something from one place to another.
For example, a traditional hose pipe transports water from a tap to a sprinkler or showerhead.
Contents
Inter-Process Communication
There are multiple uses for pipes in computing.
One of them is to enable inter-process communication.
Modern computers use something called virtual memory.
A pipe is a way to communicate between processes.
However, this makes it a little tricky to communicate when you actually want to.
In C, a pipe must be opened by a process.
It can only then be shared with another process by forking that process.
The child process, and all of its children, too, have access to the pipe.
No other processes can jump into the pipe.
A pipe can be read or written to like a file.
Instead of being written permanently to disk, though, its written as a FIFO stream to memory.
This means that once the data is read from the pipe, its removed.
You could do this in separate passes, keeping everything in the file.
The other option is to do it all with one command using pipes.
To sort, you’re able to use the sort command.
To delete duplicates, it’s possible for you to use uniq.
That is done, conveniently enough, using the pipe symbol |.
To use the pipe symbol, you jlace it between two commands.
It takes the output of the first command and provides it as the input for the second command.
As the pipe completely intercepts the output, this doesnt even print the output at the intermediate steps.
The only result is the output from uniq.
Conclusion
In computing, a pipe is a method of communicating between two processes.
This can be a child and parent process via a memory-mapped file.
It can also be by piping one commands output to anothers input.