getopt
Parse command-line arguments. More information: https://www.gnu.org/software/libc/manual/html_node/Getopt.html.
-
Parse optional
verbose/versionflags with shorthands:
getopt --options vV --longoptions verbose,version -- --version --verbose -
Add a
--fileoption with a required argument with shorthand-f:
getopt --options f: --longoptions file: -- --file=somefile -
Add a
--verboseoption with an optional argument with shorthand-v, and pass a non-option parameterarg:
getopt --options v:: --longoptions verbose:: -- --verbose arg -
Accept a
-rand--verboseflag, a--acceptoption with an optional argument and add a--targetwith a required argument option with shorthands:
getopt --options rv::s::t: --longoptions verbose,source::,target: -- -v --target target
License and Disclaimer
The content on this page is copyright © 2014—present the tldr-pages team and contributors.This page is used with permission under Creative Commons Attribution 4.0 International License.
While we do attempt to make sure content is accurate, there isn't a warranty of any kind.