In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to use the pipeline command of Linux". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "how to use the pipeline command of Linux" can help you solve the problem.
Pipeline is a communication mechanism between multiple processes. Because the data transmitted by the pipeline is unidirectional, it takes the output (stdout) of each previous process directly as the input (stdin) of the next process.
Pipe command
Command1 | command2 | command3 operator is "|", which can only handle the correct output information sent through the previous instruction, but has no direct processing ability for error information. Then, pass it to the next command as standard input.
Output description of the management command:
The correct output of [instruction 1] is used as the input of [instruction 2] and then the output of [instruction 2] is used as the input of [instruction 3], and the output of [instruction 3] will be displayed directly on the screen.
After passing through the pipeline, the correct output of [instruction 1] and [instruction 2] is not displayed on the screen.
[reminder]:
\ 1. The pipe command only handles the correct output of the previous command, not the error output.
\ 2. The command to the right of the pipe command must be able to receive standard input stream commands.
III. Pipeline application
1. Read out the contents of the logcat.log file and forward it to grep as input through the pipeline
Cat logcat.log | grep-n 'ActivitManager'
# 2. Read out the contents of the logcat.log file, forward it to grep as input through the pipeline, filter the lines containing 'Displayed', and then forward the output as input to the next grep through the pipeline.
Cat logcat.log | grep-n 'Displayed' | grep?
# 3. Read out the contents of the logcat.log and wirelessqa.log files, the wrong contents will be printed on the screen, and the correct ones will be transmitted to grep through the pipeline.
# 4. Read out the contents of the logcat.log and wirelessqa.log files, the contents of the error will be redirected to / dev/null, and the correct ones will be piped to grep
# 5. The readout logcat.log is piped to the ls, and the previously read data is lost because ls does not support standard input.
Reasonable use of pipeline commands can greatly improve work efficiency.
This is the end of the content about "how to use Linux pipe commands". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.