1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-23 17:35:28 +02:00

getopt: add page (#6990)

This commit is contained in:
Janek 2021-10-23 20:36:21 +02:00 committed by GitHub
parent ae019ca6fe
commit e9045f60a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

20
pages/linux/getopt.md Normal file
View file

@ -0,0 +1,20 @@
# getopt
> Parse command line arguments.
> More information: <https://www.gnu.org/software/libc/manual/html_node/Getopt.html>.
- Parse optional `verbose`/`version` flags with shorthands:
`getopt -o vV --longoptions verbose,version -- --version --verbose`
- Add a `--file` option with a required argument with shorthand `-f`:
`getopt -o f: --longoptions file: -- --file=somefile`
- Add a `--verbose` option with an optional argument with shorthand `-v`, and pass a non-option parameter `arg`:
`getopt -o v:: --longoptions verbose:: -- --verbose arg`
- Accept a `-r` and `--verbose` flag, a `--accept` option with an optional argument and add a `--target` with a required argument option with shorthands:
`getopt -o rv::s::t: --longoptions verbose,source::,target: -- -v --target target`