Skills of Flexible Calling Functions of Shell Scripts

I personally think that there are two ways to call the function of the script: one is to fix the function directly in the script in advance, and the other is to call the function by parameter, and call the function name as the parameter.
The first type of function is fixed and not flexible.
Skills of Flexible Calling Functions of Shell Scripts
The second type is to call a function by passing parameters. This method is more flexible.
Skills of Flexible Calling Functions of Shell Scripts
Passing parameters is substituted as follows. $1 is actually parameter 1, which is the name of the function
Skills of Flexible Calling Functions of Shell Scripts
so that it can be called very flexibly. But you will find a problem, that is, if you write a lot of methods later, you must add logic code in the case to call the method,
Skills of Flexible Calling Functions of Shell Scripts
so you need to
Skills of Flexible Calling Functions of Shell Scripts
verify the script optimization results. In
Skills of Flexible Calling Functions of Shell Scripts
this case, no matter how many method names I have, I can do it. transfer

Guess you like

Origin blog.51cto.com/14483703/2595336