← All Exercises
Getopts for CLI Options
intermediatebash
Background
Getopts provides standard CLI option parsing for bash scripts.
Problem
Create a script that accepts -f, -v, and -o options with arguments using getopts.
Input
Command-line arguments
Output
Parsed options and values
Sample tests
Sample 1
Input: script.sh -f input.txt -v -o output.txt
Expected: options parsed
Your solution
Learning objective
Learn CLI argument parsing in bash scripts