In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 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 the Bash command sequence in linux, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
Command sequence
In Linux, we can use control characters (;, & &, | |, &) to control how commands are executed. The [&] control character enables commands to open a sub-Shelll and executes in the background; using [;] control characters can combine multiple commands, but there is no logical relationship between multiple commands and can only be executed sequentially; using [& &] control characters can also combine multiple commands, but only the commands following the [& &] control character will be executed after the current command has been successfully executed. The effect of the [| |] control character is the opposite of that of [& &]. The command following the [| |] control character will be executed only if the current command fails. The following is demonstrated by an example.
1)。 Firefox browser starts through the front end, so that the current Shell will be temporarily unavailable:
[root@centos6 ~] # firefox
2)。 Running the browser in the background does not affect the use of the current Shell:
[root@centos6 ~] # firefox &
3)。 All commands are executed sequentially (regardless of whether the previous command is successful or not, the subsequent command must be executed normally:
[root@centos6] # ls / tmp; ls / root; ls / home
4)。 Displays the contents of a file if it exists, otherwise an error is reported (cat will be executed only if ls executes successfully):
[root@centos6] # ls test.txt & & cat test.txt
5)。 Open the program if you have a gedit editor, otherwise open the vim editor:
[root@centos6 ~] # gedit | | vim
6)。 If the id tom execution is successful, the screen will display Hi,tom if the user exists, otherwise No such user will be displayed:
[root@centos6 ~] # id tom & > / dev/null & & echo "Hi,tom" | | echo "No such user"
Example 5 first masks all the output of the id command with the & > redirector, and then uses & & and | | to determine whether the id command is executed successfully. If it succeeds, it displays a greeting, otherwise it shows that there is no such user.
Thank you for reading this article carefully. I hope the article "sample Analysis of Bash Command sequence in linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related 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.