In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article to share with you is about the use of the $symbol in linux, Xiaobian think it is very practical, so share it with you to learn, I hope you can gain something after reading this article, not much to say, follow Xiaobian to see it.
The $symbol has three uses in linux.
Usage 1:
Show script parameters ($0,$?,$*,$@,$#,$$,$!) (This is essentially a variable substitution.)
$0: is the bash file name, single digits, can be used directly, but more than two digits, you must use the {} symbol to enclose, such as ${10}.
$?:Is the return value of the previous instruction, success is 0, unsuccessful is 1. In general, UNIX(linux) system processes end by executing the system call exit(). This return value is the status value. Returns to the parent process to check the execution status of the child process. The return value of a command program is 0 if it succeeds and 1 if it fails.
$*: The content of all script parameters: the parameters that call this bash shell.
Usage 2:
Gets the values of variables and environment variables.
For example: path=2, then echo $path or echo${path} shows the value of path.
In linux and unix sh, strings starting with $represent variables defined in sh. These variables can be automatically added by the system or defined by the user.$PATH represents the command search path of the system, and $HOME, which is the same as %path% of windows, represents the user's home directory.
Usage 3:
The difference between $(),$( ),`` and ${ } in shell.
Description:
${ } This form is actually the same as Usage 1 and 2, and belongs to the category of variable substitution, except that curly brackets can be added to variable substitution, or brackets can be omitted.
In short: $(( )) belongs to the execution calculation formula, equivalent to $[ ],$( ) and ` ` belongs to the command substitution,${ } belongs to the variable substitution.
1.$( ) and ``(backquotes): return the result of the command in parentheses
In bash,$( ) and ` `(backquotes) are used as command substitutions, executing commands enclosed in parentheses or backquotes.
Command substitution is similar to variable substitution. It is used to reorganize the command line. First, complete the command line in quotation marks, then replace the result, and then reorganize it into a new command line.
2,${ } Variable substitution
In general,$var and ${var} are indistinguishable, but using ${ } defines the scope of variable names more accurately.
The above is how to use the $symbol in Linux. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.