Home >System Tutorial >LINUX >What are pipes and named pipes used for in Linux? One article will help you understand
The editor will share with you the uses of pipelines and named pipes in Linux. I believe that most people don’t know much about it, so I share this article for your referencelinux named pipe case, I hope you will After reading this article, I have gained a lot. Let’s find out together!
In Linux, pipe allows you to send the output of one command to another command. Pipes, as their name suggests, can redirect the standard output, input and errors of one process to another process linux named pipe case arm linux for further processing.
The sentence pattern of the "pipeline" (or "unnamed pipeline") command is to add the | character between the two commands:
Command-1 | Command-2 | ...| Command-N
Here, the pipeline cannot be accessed through another session; it is temporarily created to receive the execution of Command-1 and redirect the standard output. It is deleted after successful execution.
In the previous example, contents.txt contained a list of all the files in a specific directory—specifically, the output of the ls-al command. We first grep the file names from contents.txt using the "file" keyword through the pipeline (as shown in the figure), so the output of the cat command is provided as input to the grep command. Next, we add a pipeline to execute the awk command, which displays column 9 of the filtered output of the grep command. We can also estimate the number of lines in contents.txt using wc-l command.
A named pipeline continues to be used as long as the system is up and running or until it is deleted. It is a special file that adheres to the FIFO (first in, first out) mechanism. It can be used like a normal file. That is, you can write to the Linux operations blog, read from it, and then turn it on or off. To create a named pipeline, the command is:
mkfifo
This will create a named pipeline file which can even be used across multiple shell sessions.
Another way to create a FIFO named pipe is to use this command:
mknod p
To redirect the standard output of any command to another command, use the > symbol. To redirect the standard input of any command, use
The above is the detailed content of What are pipes and named pipes used for in Linux? One article will help you understand. For more information, please follow other related articles on the PHP Chinese website!