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

How to use the set command in Linux

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces how to use the set command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

You can set various shell options or list shell variables with the set command. A single option sets commonly used properties. The-o parameter turns on special features after some options. Using the + o parameter after some options will turn off some features, and the set command without any arguments will display all variables of shell. Set always returns ture. Unless an illegal option is encountered.

When BASH shell is called, all options can be listed. The current option set is listed in $-. After the option parameter is processed, the other parameters are assigned to the location parameter ($1, 1, 7, 2, 5, 5, 5, 2, 5, 2, 5, 2, 1, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,

Set [--abefhkmnptuvxldCHP] [- o option name] [arguments...]

Source code:

Option description

-an automatically marks variables that have been modified or for subsequent commands to be exported

-b does not precede the original prompt, but immediately triggers the status table that terminates the background task

-e if the command returns with a non-zero value, exit immediately

-f forbids paths with extensions

-h locates and stores function commands when defining functions, and usually queries function commands when functions are executed

-k all keyword parameters, not just those in front of the command name, are placed in the environment command

-m monitor mode to start task control. This option supports system shell interaction by default. The background process runs as a separate process group, displaying the status line with exit each time the task is completed

-n reads the command but does not execute it. Usually monitor shell scripts for syntactic errors. Interactive shell ignored

The-o option-name option name can be one of the following:

Option description

Allexport is the same as-an option

Braceexpand shell performs curly braces extension, which works by default

Emacs uses an emacs-style command line editing interface. Unless shell is started with the-noline-editing option, this option is enabled by default when shell interacts

Errexit with-e option

Histexpand same as-H option

The result of ignoreeof is as if the shell command IGNOREEOF=10 was executed

Interactive allows words to be preceded by a # sign so that all characters on the command line-commands are ignored in the interactive shell

Monitor same as-m option

Noclobber same as-C option

Noexec same as-n option

Noglob same as-f option

Nohash same as-d option

Notify same as-b option

Nounset with-u option

Physical same as-p option

Posix changes the BASH attribute to match the standard, and the default operation is different from the POSIX1003.2 standard.

Verbose same as-v option

Vi uses a vi-style command line editor

XTRACE is the same as the-x option. If no option name is given, the current option value is displayed.

-p turn on privileged mode (where the $ENV file is processed and cannot be inherited from the environment

Shell function. If it is a valid user ID rather than a real user group, it starts automatically. Turning off this option will cause valid users and groups IDs to set real users and groups IDs)

-t exits after reading the command and executing it

-u treats a non-set variable as an error when performing parameter expansion (shell displays an error message if an extension attempts to appear in a non-set variable. If it is not interactive, exit with a non-linear value)

The shell input line is displayed when the-v input line is read

-x displays the PS4 extension value after each simple command is extended, followed by the command to be executed

-l Save and restore the name bound in the command

-d disables the execution of the lookup hash command (usually, the command is saved in the hash table and does not continue to search once it is found)

-C effect seems to have executed the noclobber=shell command.

-H use! Historical replacement of style (this option is valid by default when shell interacts)

-P if this parameter is set, when the change directory command cd is executed, the symbolic link is not followed, but the actual directory is used

If there are no parameters after the option, the position parameter is not set. Otherwise, even if some parameters start with the an option, set the position parameter to the signal of the argument- end option, which will cause the remaining parameters to be assigned to the position parameter (the-x and-v options are turned off. If there is no argument, the position parameters will retain the unchanged parameters)

Thank you for reading this article carefully. I hope the article "how to use set commands 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.

Share To

Servers

Wechat

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

12
Report