In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
I. shell script format
#! / bin/bash
The first line is to specify which program to compile and execute the script
The comment begins with a "#"
Second, the difference between script execution source, sh, bash,. / execution script
1. The dot command is just a dot symbol (from Bourne Shell) is another name for source
2. The source command (from C Shell) executes the built-in commands of bash shell
3. Bash / bin/bash command is more powerful than sh.
4. Sh / bin/sh command
5. Export can add, modify or delete environment variables for use by subsequent programs. At the same time, it is important that the effectiveness of export is only limited to that login operation. Log out or reopen a window, and the environment variables given by the export command no longer exist.
Export PATH=/bin/bash:$PATH
6. (click source bash sh. / file name for execution) the difference between them
Point and source execution are equivalent; that is, both execution methods execute the script in the current shell process, rather than restarting a shell and executing the script in the child shell process.
The execution files of 6.2:bash sh (which can be executed without permission) are different.
. / (execution permission is required) the three execution methods are equivalent; all three ways to execute the script are to restart a child shell and execute the script in the child shell.
6.3: verification result:
[root@localhost ~] # name=dangxu / / define general variables
[root@localhost ~] # echo ${name}
Dangxu
[root@localhost ~] # cat test.sh / / validation script to instantiate. / * .sh in the title
#! / bin/sh
Echo ${name}
[root@localhost ~] # ls-l test.sh / / verify that the script is executable
-rwxr-xr-x 1 root root 23 Feb 6 11:09 test.sh
[root@localhost] #. / test.sh / / the following three commands prove the first conclusion
[root@localhost ~] # sh. / test.sh
[root@localhost ~] # bash. / test.sh
[root@localhost] #. . / test.sh / / the following two commands prove conclusion two
Dangxu
[root@localhost ~] # source. / test.sh
Dangxu
[root@localhost ~] #
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.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.