There are two types of programming languages
Strong type: such as C language. The data has a specific type that is declared before it can be used. Data operations must conform to type requirements (e.g., string type data cannot be arithmetic directly with integer data)
Weak type: such as Shell. Data defaults to character type and should not be declared beforehand. The data type is automatically converted when the data is operated.
Variable
Variable naming rules:
- The variable is made up of letters, numbers, and underscores.
- You can't start with numbers.
Variable types: Local variables, environment variables, local variables, special variables (built-in), parameter variables, read-only variables.
Note that if the variable is not defined in the shell's configuration file, then his life cycle is just the current shell process, and an exit fails.
Scope Example:
Local variables
Environment variables: Child shell also works
Examples of variable definitions:
Variable references (supplemental to the above table):
"" (double quotation marks): A weak reference in which the variable reference is replaced with the variable value "(single quote): A strong reference where the variable reference is not replaced with the value of the variable, and the original string is persistedVariable Reference ExampleShell script Programming
Take advantage of the process-oriented programming of commands and programming components on the system.
Bash configuration files: Profile class and BASHRC class
Profile class: Provides configuration for the interactive logon shell
BASHRC class: Provides configuration for a non-interactive logon shell
Interactive: Enter the username and password via the terminal to login and call the shell
Shell opened after login via Su-username or su-l username
Configuration file Read Order:/ETC/PROFILE-->/ETC/PROFILE.D/*-->~/.BASH_PROFILE-->/ETC/BASHRC
Non-interactive: Login performed via SU username
Terminal opened under GUI graphical interface
Run the shell opened in the script file
Configuration file Read order: ~/.BASHEC-->/ETC/BASHRC--->/etc/profile.d/*
Summary: The difference between the two can be simply said to be-whether you need to enter a password.
Example of a configuration file modification takes effect
Modifying a profile does not take effect immediately you can use. or source to forcibly reread the configuration file so that the changes take effect immediately
First modify the. nashrc file to add alias Ech= ' echo $PATH '
Using alias does not print out the command alias we just added, using Ech direct error
Using the alias command after rereading the configuration file with the source file, you can see our newly added Ech.
Linux--shell Programming Basics