The problem is as follows: perform a loop based on the number of Script Parameters $ #, and output each parameter $1 $2 $3 in sequence ...... I have a loop variable I $ I. When I get this variable I is 1, I want to use this 1 and then call $1, that is, print out the first parameter $ ($ I) of course, $ ($ I) is not useful.
After a long struggle at that time, I finally asked hundreds of questions. The two experts gave the answer:
1)
#! /Bin/shnumber =$ # echo $ Numberi = 1 while [$ I-Le $ number] DOA [$ I] = $1 # assign an array a [I] to $1, that is, the first parameter is obtained and the value is saved to a [1] echo $ {A [$ I]} (I ++) # The array is removed by one digit, change to a [2] shift # Use the shift command to move the parameter one bit behind, in this case, $1 is the second done parameter, and the data in the array a [Key] contains the number of keys in $ {A [Key]}. For example: the value of a [1] is $1.
Of course, the first method is not usable for me.
2)
#! /Bin/Basha = ([email protected]) # obtain all parameters from [email protected] and save the parameters to afor I in $ {A [@]}; do # loop echo $ idone using I in each parameter