1. Add-x to execute the shell script, and list the process when executing the script! (For beginners like me) sh-x shell (. /shell can also execute shell scripts, but there is no-x parameter) 2. when the number of passed values is greater than the read-defined accept variable, extra values are given to the last variable !! 3. expr is used to calculate Integer Variables. If the calculation result is not all after the integer decimal point, it is omitted (the multiplication character must be an escape character '\'). 4. execute an output command (pgrep mysqld) in the shell script. How can I assign the output result to the variable as a value? Web = $ (/usr/bin/pgrep mysqld) # You can use the variable =$ (command) and variable = 'COMMAND 'to assign the result of command execution to the variable.
If [$ web =]
Then
/Etc/init. d/mysql start
Fi
5. You can use the whereis/which/type command to view the location of a command. 6. The application of the awk command: Segment extraction! (One row is used for segmentation) awk-F [separator] 'condition action'/object example: awk-F: '$3 = 0 {print $1}'/etc/passwd example: awk-F: '$1 = root {print $1}'/etc/passwd #-F: use: split the content of each row of passwd ($1 refers to the content of the first section $2 refers to the content of the second section $ n refers to the content of the n section) # The match command and the print action match $3 = 0 in single quotes. The third section equals 0. print {print $1}. print the first section ($3 = 0. Match the first line of the trip)