What is a shell?
The shell is a scripting language aming_linux blog.lishiming.net
You can use logical judgments, loops, and other syntax
Functions can be custom-defined
The shell is a collection of system commands
Shell scripts enable automated operations, which can greatly increase our operational efficiency
Shell script structure and execution methods
Need to add #!/bin/bash at the beginning
Lines that begin with # are interpreted as explanatory notes
The name of the script ends with. SH and is used to differentiate between this is a shell script
There are two methods of executing
chmod +x 1.sh;./1.sh
Bash 1.sh
View the script execution process bash-x 1.sh
See if the script is syntactically incorrect bash-n 1.sh
Date command
Variables in shell scripts
You should use a variable instead when you use a string more frequently in your script and the string length is long
When using conditional statements, the variable if [$a-gt 1] is often used; Then ...; Fi
When referencing the result of a command, replace n= with a variablewc -l 1.txt
When writing and user interaction scripts, variables are also essential for read-p "Input a number:" N; Echo $n If you don't write this n, you can use $reply directly.
Built-in variables $, $ $, $ ... $ $ represents the script itself, the first parameter, the $ A second ... $ #Number of parameters
Mathematical Operation a=1;b=2; c=$ (($a + $b)) or $[$a + $b]
Shell,shell script structure and execution method, data command, variables in shell script