Handle flags in shell scripts.
Section: Script Execution and Utilities
Parse short options with getopts
bash
bash
while getopts ':f:n:' opt; do case "$opt" in f) file="$OPTARG" ;; n) count="$OPTARG" ;; esac; doneExplanation
Useful for small production scripts with predictable CLI flags.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Script Execution and Utilities