InShellProgramming.You can use parameters.ShellLocation and Internal Parameters
1 ,Location parameters The parameters provided by the system are called location parameters. The value of the location parameter can be used $ N Get, N Is a number. 1 , That is $1. Similar C Array in language, Linux Segment the input command string and label each segment. 0 Start. The 0 No.ProgramName, from 1 It indicates the parameter passed to the program at the beginning. For example $0 Indicates the program name, $1 Indicates the first parameter passed to the program, and so on. 2,Internal Parameters In the above process$0Is an internal variable, it is required, and$1It is optional. And$0The same internal variables include the following. $ #----Total number of parameters passed to the program $? ----PreviousCodeOrShellProgram inShell. If it Exits normally, return0And vice versa0Value. $ *----A string consisting of all parameters passed to the program. The following is an example. [Root @ server TMP] # Cat test. Sh #! /Bin/bash # Test shell Echo $0 Echo $1 Echo $2 Echo $? Echo $ * Echo $ # [Root @ server TMP] #./test. Sh yema bhanv Edu Network ./Test. Sh // program name Yema // The first parameter Bhanv // The second parameter 0 // program execution result Yema bhanv Edu network // string consisting of passing Parameters 4 // number of parameters