Program: Instruction + data
Program Programming Style:
Program: command-centric, data-serving instruction
Object type: Data-centric, instruction serves data
Shell program: Provides programming capabilities to interpret execution
How to handle the programming logic:
Sequential execution
Loop execution
Select Execute
Shell programming: procedural, interpreting execution
The basic structure of the programming language:
A combination of various system commands
Data storage: variables, arrays
Expression: A + b
Statement: If
Shell script:
A text file that contains some commands or declarations and conforms to a certain format
Format requirements: First line shebang mechanism
#! /Bin/bash
#! /usr/bin/python
#!/usr/bin/perl
The uses of shell scripts are:
Automating common commands
Perform system administration and troubleshooting
Create a simple application
Working with text or files
Create a shell script
First step: Use a text editor to create a text file
The first line must include the shell declaration sequence: #!
#! /bin/bash
Add Comment
Comments start with #
Step two: Run the script
Give execute permission to specify the absolute or relative path of the script on the command line
Run the interpreter directly and run the script as a parameter of the interpreter program
Scripting specifications
1. The first line is generally the language used for the call
2. Program name, avoid changing the file name to not find the correct file
3. Version number
4. Time after the change
5. Related information of the author
6. The role of the procedure, and matters needing attention
7. Finally, a brief description of the updates for each version
Basic structure of the script
#! Shebang
CONFIGURATION Vriables
Function_definitions
Main_code
Programming Basics for Shell scripts