getopts 'ab:' opt

Category: Shell & Bash

getopts 'ab:' opt

Parse short options in a shell script

Parses command-line options (like -a or -b value) in scripts. The colon after b means it expects a value.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.