In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the example analysis of redirection and pipeline in Linux, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
Anyone who knows anything about shells knows that pipes and redirects are very useful IPC mechanisms in Linux. In shell, we usually use the "|"to represent pipes, symbols">"and"
redirected
Input and output of system settings
Default Output Device: standard output, STDOUT, 1 default input device: standard input, STDIN, 0 standard error output: STDERR, 2 standard input: keyboard standard output and error output: monitor I/O redirection standard input (stdin): code 0, use standard output (stdout): code 1, use> or>>; standard error output (stderr): code 2, use 2> or>>;">">: override output>>: append output # set -C prohibits overwrite redirection for existing files; force overwrite output, use>|# set +C turn off the above function "2>" "2>>"2>: redirect error output 2>>: append the correct and incorrect ones to different files # ls /varr > /tmp/var3.out 2> /tmp/err.out# ls /varr > /tmp/var4.out 2> /tmp/var4.out /dev/null Trashcan Black Hole Device &>: Redirect standard output or error output to the same file (or 2>&1)"Output redirection # tr 'a-z' 'A-Z'"Here Document # cat # cat >>/tmp/myfile. txt/dev/null, software device, bit bucket, data black hole, direct content output to this device No return content pipeline
A pipe is a command that takes the output of the previous command as the input to the next command1| command 2| command 3| ……
# echo "hello world. " | tr 'a-z' 'A-Z'# echo "redhat" | passwd --stdin hive# cut -d: -f1 /etc/passwd | sort | tr 'a-z' 'A-Z' # echo "Hello,World. " | tee /tmp/hello.out # tee: Display content and save content in a file # wc -l /etc/passwd |cut -d''-f1 Exercise: 1. Count the number of files in/usr/bin/directory; 2. Remove all user shells on the current system, and require that each shell be displayed only once and in order; 3. Thinking: How to display the content type of each file under/var/log directory? Remove line 6 of the/etc/inittab file; 5. Remove the user name and shell of the ninth user from the/etc/passwd file, display it on the screen and save it to the/tmp/users file; 6. Display all files starting with pa under/etc directory, and count their number; 7. Do not use a text editor, add alias cls=clear to the current user's.bashrc file; thank you for reading this article carefully, and hope that Xiaobian shares the "Example analysis of redirection and pipelines in Linux" This article is helpful to everyone, and I hope that everyone will support it a lot, pay attention to the industry information channel, and more relevant knowledge is waiting for you to learn!
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.