Recently, shell has been used. It is very simple and has no logic. I wrote it here just to help myself remember it. It's just a messy note. I hope this will help you. Please advise me more.
1 If else
If [$ #-lt 5]; then
Help
Exit 1
Else
Do something...
Fi
Where-lt is equivalent to <
-GT is equivalent to>
2 while
The followingProgramExecute the loop 101 times. Note that-Ge is greater than or equal
X = 100
While [$ X-GE 0]
Do
Something...
(X = x-1) // note that the operation in Shell needs to be written like this
Done
3 built-in Variables
$0 |
Equivalent to C LanguageMain FunctionArgv [0] |
$1 ,$2 ... |
These are called positional parameter, which is equivalent to the C LanguageMain FunctionArgv [1] ,Argv [2] ... |
$ # |
Equivalent to C LanguageMain FunctionArgc-1 , Note that# Not comment |
$ @ |
Parameter List"$1" "$2 "... For exampleFor In the loopIn . |
$? |
Exit status of the previous command |
$ |
Process Number of the Current Shell |
4. Date command usage
Common commands date-d "condition" Format
For example, date-d "yesterday" + % Y % m % d gets 20120201