In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "linux how to shell and sub-shell", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "linux how shell and sub-shell" article.
There are two ways for Linux to execute Scripts. The main difference lies in whether to establish subshell or not.
1. Source filename or. Filename
Do not create subshell, read and execute commands in filename in the current shell environment, which is equivalent to sequential execution of commands in filename
2. Bash filename or. / filename
Create a subshell and create a new child shell to execute the command in the filename in the current bash environment. The child shell inherits the variables of the parent shell, but the child shell cannot use the variables of the parent shell unless you use export [Note: this is similar to the namespace, even to the functions in c]
The properties inherited by the child Shell from the parent Shell are as follows:
Current working directory environment variables standard input, standard output, and standard error output signals ignored by all open file identifiers
The attributes that the child Shell cannot inherit from the parent Shell are summarized as follows:
Signal processing 3. $(commond) that Shell variables are not ignored except for environment variables and variables defined in .bashrc files
Its function is to make the command execute in the child shell
4. Commond
It's similar to $(commond). The "`" symbol here is a prime (anti-single quotation mark), not a single quotation mark, but the key below the Esc key on the keyboard. ]
5. Exec commond
Replacing the current shell does not create a new process. The pid of the process remains the same: the built-in command exec of shell will not start the new shell, but will replace the current shell process with the command to be executed, and clean up the environment of the old process, and other commands after the exec command will no longer be executed. When exec ls is executed in a shell, the current directory is listed, and the shell exits itself. (subsequent commands are no longer executed) because the shell has been replaced with a process that only executes the ls command, the end of execution naturally exits. You can use sub shell to avoid this effect when needed. Generally, put the exec command into a shell script, call the script with the main script, and use bash a.sh at the call point (a.sh is the script in which the command is stored). This will create a sub shell for a.sh to execute. When executed to exec, the subscript process will be replaced with the corresponding exec command.
The above is about the content of this article on "how to shell linux and sub-shell". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, 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.