01.Shell programming
Shell create and running
- The first line of the shell script is to set the shell interpter.
| |
source script-nameor “.” is to read or load which shell variable in the shell script.sequeues to load variables in the shell scripts . When we use command
source ./fileor. fileto load varialbe. the shell will excuted in the same shell as we just run it in the same shell.
when we run sh shell_script.sh, it will open a new shell interpter to run it. when the shell excute end. the shell will ended. and the variable will not be read into current we excuted.
shell tips
- Indicator the shell interpter at the 1st line of the shell script
| |
or
| |
- shell Add more informaton in the comments
| |
environment variable initial and loading config file sequques
- system user login the shell
graph TD
A[ /etc/profile ] --> B( /etc/profile.d )
B --> C[ $HOME/.bash_profile ]
C --> D[ $HOME/.bashrc ]
D --> E[ /etc/bashrc ]
- nolgin interactive shell
- runing script without interactive shell
graph TD
A[ $HOME/.bashrc ] --> B[ /etc/bashrc ]
