Update cheatsheets

This commit is contained in:
ivuorinen
2024-02-21 11:19:49 +00:00
parent 4e88a1b42f
commit 3d653cc7e6
4803 changed files with 127002 additions and 0 deletions

25
linux/getopt Normal file
View File

@@ -0,0 +1,25 @@
---
syntax: markdown
tags: [tldr, linux]
source: https://github.com/tldr-pages/tldr.git
---
# 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 --options vV --longoptions verbose,version -- --version --verbose`
- Add a `--file` option with a required argument with shorthand `-f`:
`getopt --options f: --longoptions file: -- --file=somefile`
- Add a `--verbose` option with an optional argument with shorthand `-v`, and pass a non-option parameter `arg`:
`getopt --options 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 --options rv::s::t: --longoptions verbose,source::,target: -- -v --target target`