1 Case-sensitive
UNIX is case-sensitive, so shell scripts are case-sensitive
2 special characters
Some characters of Unix have special meanings or functions that must be escaped if they are not used in their special sense (escaped).
In order to escape, they need to be surrounded by backslashes or single quotes.
3 shell
The shell (command-line interpreter) is an environment that can be used to run commands, programs, and shell scripts.
4 shell scripts
A shell script is an organic combination of commands.
Shell scripts and functions are interpreted, ASCII text, and cannot be compiled.
5 functions
Functions are written similar to scripts, except that functions are defined and called in scripts.
The function form is as follows:
function Function_name{commands to execute}
Or
Function_name () {commands to execute}
To declare or define a function before it is called, the function part must appear before the command statement that invokes the function.
6 Running shell scripts
If you do not use the corresponding shell to run then you need to add executable permissions
7 comments and styles in shell scripts
Good annotation and code writing styles are important for readability
8 Control structure
If ... then
If ... then ... else
If ... then ... elif ... (ELSE)
For ... in
While
Until
Case
9 using the break, continue, exit, and return statements
Here documentation
Here documentation is used to redirect input to an interactive shell script or program.
One-to-one shell script commands
Table 1 UNIX Commands overview
There should be a table here
12 Symbol command
The symbols in table 2 are actually commands.
Table 2 symbol commands
There should be a table here
13 variables
A variable is a string that can be assigned to a value that includes numbers, text, file names, devices, or any other type of data.
In order to access the data that the variable refers to, you need to add a $ before the variable, and you cannot have spaces.
14 Command-line arguments
The command-line argument, $1,$2,$3,...,$9, is the positional parameter, which points to the actual command, program, shell script, or function.
$0,$2 in a function, etc., are used by the function itself and may not appear in the Shell scripting environment in which the function is called.
The shift command
The Shfit command is used to move the positional parameters to the left, such as the shift command to make the $ $ $.
You can also use shift to move multiple positions, and shift 3 causes the $4 to move to the location.
16 Special parameters $* and [email protected]
$* and [email protected] Allow access to all command-line arguments at once.
$* and [email protected] have the same functionality unless you enclose them in double brackets.
"$*" takes the entire argument list as a parameter to get
"[Email protected]" Gets the entire parameter list and splits it into different parameters
17 double quotes ", symbols" and "
In statements that allow character substitution or command substitution, you can use double quotation marks to define variables that contain spaces, and you need to use double quotes "
You can use ' in a statement that does not allow character substitution or command substitution. The purpose of using ' surround ' is to use body text without any substitution.
Use ' When you want to execute a command or script and replace its output.
18 using awk in Solaris
Awk in Solaris is Nawk, and you can add the following code when you write a script
Case $ (uname) Insunos) alias Awk=nawk;; Esac
19 using the echo command correctly
For example, in some shells, echo-e "\ n" wraps.
There's some echo "\ n" on it.
If the script uses */bin/bash, you can add the following statement
Case $SHELL In*/bin/bash) alias echo= "Echo-e";; Esac
The math in shell scripts
21 built-in math functions
22 file permissions, suid, and Sgid programs
23 Run the command on the remote host
Shell script programming Getting started to abort