In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
The first time I looked at shell
1. Script interpreter settings
The first line of the script: #! / bin/sh
[root@SUN sun] # cat test.sh
#! / bin/sh
First, the first line can be split into two parts, #! And absolute path, #! It's just a special token, #! Followed by the interpreter address (that is, the shell storage path). Note that the shell path must be full path. In fact, the first line does not have to be written, it can be omitted, do not write the first line, you can manually specify shell, for example: sh test.sh, manually specify shell, script files do not need to require execution permission.
2. Shell's process of executing the script
A. Execute interactive commands
When the user enters the terminal, the shell process has been run, and the user enters a command. If it is an internal command in shell (such as cd,exec), a new process will not be created at this time. The internal command is actually a subfunction in shell, and the execution of the current process is completed. If it is an external command (such as ls,rm), the shell process will first fork a child process, call exec to execute the command, and the parent process calls wait () or waitpid () to wait for the child process to finish.
B. execute the script file
The shell process first fork a child process, and then calls exec to execute the script file. At this time, another set of mechanisms for exec execution are executed. Exec will read the first line of the text file. If an interpreter is specified, the specified interpreter will be called. Execution starts from the interpreter's _ start, and the contents of the script file will be passed to the interpreter as parameters.
3. View the current methods of using shell
(1) echo $SHELL
[root@SUN Desktop] # echo $SHELL
/ bin/bash
(2) ps
[root@SUN Desktop] # ps
PID TTY TIME CMD
3246 pts/0 00:00:00 bash
3269 pts/0 00:00:00 ps
(3) enter a command that does not exist, abcd
[root@SUN Desktop] # adcd
Bash: adcd: command not found
(4) ehco $0
[root@SUN Desktop] # echo $0
/ bin/bash
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.