Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of the set command in Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what the role of the set command in Linux, I believe that most people do not understand, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The common Linux command set command is mainly used to display the shell variable that already exists in the system and to set the new variable value of the shell variable.

Set displays or sets shell properties and shell variables

Add that when you use set to change the shell property, the symbols "+" and "-" turn on and off the specified mode, respectively. The set command cannot define a new shell variable. If you want to define a new variable, you can use the declare command to define it in the format of variable name = value.

Syntax set (option) (parameter) option-a: marks the modified variable for output to the environment variable. -b: causes the aborted daemon to report the execution status immediately. -C: the file generated by the redirection cannot overwrite an existing file. -d:Shell presupposes to use hash tables to memorize used instructions to speed up the execution of instructions. Use the-d parameter to cancel. -e: if the instruction returns a value that is not equal to 0, exit shell immediately. -f: cancel the use of wildcards. -h: automatically records the location of the function. -H Shell: available "!" Add the way to execute the instructions recorded in history. -k: the parameters given by the instruction are treated as environment variables for this instruction. -l: record the variable name of the for loop. -m: use monitor mode. -n: only the instructions are read, not actually executed. -p: starts priority mode. -P: when the-P parameter is enabled, symbolic links are replaced by the actual file or directory when the instruction is executed. -t: exit shell after executing the following instructions. -u: when undefined variables are used during execution, an error message is displayed. -v: displays the input values read by shell. -x: after the instruction is executed, the instruction and the parameters are displayed first. Parameter cancels the parameter that a set has started.

The instance uses the declare command to define a new environment variable "mylove" and sets its value to "Visual C++". Enter the following command:

Declare mylove='Visual defined new environment variables and then use the set command to output the newly defined variables as environment variables, enter the following command:

When set-a mylove # is set as an environment variable, the corresponding environment variable will be added when the command is executed. You can use the env command and the grep command to display and search for the environment variable "mylove", respectively. Enter the command as follows:

Env | grep mylove # displays the value of the environment variable. At this time, the query value of the environment variable will be output after the command is executed.

The above is all the content of the article "what is the function of the set command in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report