Let’s say you want to allow a user to pass a -v
flag to turn on verbose logging in a script. Manually parsing out options passed to a script is difficult, but in this lesson, we’ll learn about getopts
which makes it easy. We'll look at the limitations of using getopts (options must be in a format like -a
or -ab <value>
) as well as the importance of shifting processed options off of the argument array.
Does getopt
support case sensitivity? Is -a
equal to -A
?
Does
getopt
support case sensitivity? Is-a
equal to-A
? It does support case sensitivity,-a
!=-A
. I updated the footnotes for this lesson (https://github.com/ccnokes/advanced-bash-automation-for-web-developers/tree/master/12-getopts) with that 👍.