First page Back Continue Last page Graphics
The getops Function
Many scripts depend heavily upon command line arguments, or positional parameters, so writers frequently use the getopts function to make processing them easier.
It's often used for the -x form (the "dash" form) of options because of all the many combinations.
For example, consider a command which can have options -x, -y, and -z in any order and any combination (like -xz and -zx), giving at least 29 (I counted) valid combinations. You don't want to write script code for each possibility!