Ravi Sir's Cards › AWS
getopts in 4 steps
This revision card explains getopts in 4 steps. It starts from the need that list flags; colon = needs value. It describes loop with while. The how-to section notes case on the letter. An example on the card is value is in OPTARG.
Read card text
What this card says
Why do we need it?
List flags; colon = needs value.
What is it?
Loop with while.
while getopts 'vf:' o; do
How to do it
case on the letter.
Example
Value is in OPTARG.