In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you what are the common knowledge points of Shell. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The knowledge points commonly used in Shell to obtain the true value of soft connections-readlink
Readlink can help us get commands in the actual directory in the Linux environment.
# dirname "$(dirname" $(readlink-f "$(which javac | | which java)" root@devops:~# ls / usr/local/bin/ games/ jdk/ lib/ openresty/ share/etc/ include/ jdk1.8.0_171/ man/ sbin/ src/)
Root@devops:~# ls / usr/local/bin etc games include jdk jdk1.8.0_171 lib man openresty sbin share src
Root@devops:~# which javac/usr/local/jdk/bin/javac
Root@devops:~# readlink-f $(which javac) / SHELL environment where usr/local/jdk1.8.0_171/bin/javac customization scripts run-set
Set is a built-in command for BASH, and if you do not provide an option to set, the names and values of all variables and functions are printed by default.
Common options:
-u or-o nounset: non-existent variables encountered during script execution are incorrect. By default, BASH automatically ignores them.
Set-x or-o xtrace: used to output the line of command that was executed before running the result. It is usually useful when debugging scripts
-e: judge whether the command runs successfully based on the return value. Whenever an error occurs in the script, execution is terminated. But it doesn't work very well for plumbing commands. Because the pipe command takes the return value of the last command as the return value of the organize command.
+ e: turn off the-e option, which can be used for special scenarios, such as when the script is executed when the return value is non-zero.
Set-o pipefail: whenever one subcommand fails, the entire pipeline command fails.
It is generally recommended to delete the above four and put them in the header of BASH.
#! / bin/bash
Set-eux
The variable in set-p pipefail$ {YOUR_COMMAND} Shell means $0 the file name of the current script $n is passed to the parameters of the script or function. N is a number that indicates the number of parameters. For example, the first parameter is, and the second parameter is 2. $# the number of parameters passed to the script or function. $* all parameters passed to the script or function. All parameters passed to the script or function by $@. When enclosed in double quotes (""), it is slightly different from $*? The exit status of the previous command, or the return value of the function. $the current Shell process ID. For Shell scripts, it is the process ID where these scripts are located. Thank you for reading! This is the end of this article on "what are the knowledge points commonly used in Shell?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.