mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-02-08 03:45:52 +00:00
Update cheatsheets
This commit is contained in:
2
tldr/awk
2
tldr/awk
@@ -6,6 +6,8 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
# awk
|
||||
|
||||
> A versatile programming language for working on files.
|
||||
> Note: Different implementations of AWK often make this a symlink of their binary.
|
||||
> See also: `gawk`.
|
||||
> More information: <https://github.com/onetrueawk/awk>.
|
||||
|
||||
- Print the fifth column (a.k.a. field) in a space-separated file:
|
||||
|
||||
44
tldr/gawk
Normal file
44
tldr/gawk
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
syntax: markdown
|
||||
tags: [tldr, common]
|
||||
source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# gawk
|
||||
|
||||
> GNU version of awk, a versatile programming language for working on files.
|
||||
> See also: `awk`.
|
||||
> More information: <https://www.gnu.org/software/gawk/manual/gawk.html>.
|
||||
|
||||
- Print the fifth column (a.k.a. field) in a space-separated file:
|
||||
|
||||
`gawk '{print $5}' {{path/to/file}}`
|
||||
|
||||
- Print the second column of the lines containing "foo" in a space-separated file:
|
||||
|
||||
`gawk '/{{foo}}/ {print $2}' {{path/to/file}}`
|
||||
|
||||
- Print the last column of each line in a file, using a comma (instead of space) as a field separator:
|
||||
|
||||
`gawk {{[-F|--field-separator]}} ',' '{print $NF}' {{path/to/file}}`
|
||||
|
||||
- Sum the values in the first column of a file and print the total:
|
||||
|
||||
`gawk '{s+=$1} END {print s}' {{path/to/file}}`
|
||||
|
||||
- Print every third line starting from the first line:
|
||||
|
||||
`gawk 'NR%3==1' {{path/to/file}}`
|
||||
|
||||
- Print different values based on conditions:
|
||||
|
||||
`gawk '{if ($1 == "foo") print "Exact match foo"; else if ($1 ~ "bar") print "Partial match bar"; else print "Baz"}' {{path/to/file}}`
|
||||
|
||||
- Print all the lines which the 10th column value is between a min and a max:
|
||||
|
||||
`gawk '($10 >= {{min_value}} && $10 <= {{max_value}})'`
|
||||
|
||||
- Print table of users with UID >=1000 with header and formatted output, using colon as separator (`%-20s` mean: 20 left-align string characters, `%6s` means: 6 right-align string characters):
|
||||
|
||||
`gawk 'BEGIN {FS=":";printf "%-20s %6s %25s
|
||||
", "Name", "UID", "Shell"} $4 >= 1000 {printf "%-20s %6d %25s
|
||||
", $1, $4, $7}' /etc/passwd`
|
||||
@@ -14,7 +14,7 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
|
||||
- Create a here document and pass that into `stdin` (requires a multiline command):
|
||||
|
||||
`{{command}} << {{EOF}} <Enter> {{multiline_data}} <Enter> {{EOF}}`
|
||||
`{{command}} << {{EOF}} <Enter> {{multiline_text}} <Enter> {{EOF}}`
|
||||
|
||||
- Create a here string and pass that into `stdin` (achieves the same effect as `echo string |`):
|
||||
|
||||
@@ -31,3 +31,7 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
- Disregard leading tabs (good for scripts with indentation but does not work for spaces):
|
||||
|
||||
`cat <<- {{EOF}} > {{path/to/file.txt}} <Enter> {{multiline_data}} <Enter> {{EOF}}`
|
||||
|
||||
- Pass command output to a program as a file descriptor:
|
||||
|
||||
`diff <({{command1}}) <({{command2}})`
|
||||
|
||||
17
tldr/linux/decode-dimms
Normal file
17
tldr/linux/decode-dimms
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
syntax: markdown
|
||||
tags: [tldr, linux]
|
||||
source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# decode-dimms
|
||||
|
||||
> Decode RAM data.
|
||||
> More information: <https://manned.org/decode-dimms>.
|
||||
|
||||
- Display DIMM information:
|
||||
|
||||
`decode-dimms`
|
||||
|
||||
- Display help:
|
||||
|
||||
`decode-dimms {{[-h|--help]}}`
|
||||
@@ -13,7 +13,7 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
|
||||
`kde-builder --initial-setup`
|
||||
|
||||
- Compile a KDE component and its dependencies from the source:
|
||||
- Compile a KDE component and its dependencies from the source (use `workspace` to compile Plasma desktop):
|
||||
|
||||
`kde-builder {{component_name}}`
|
||||
|
||||
|
||||
@@ -20,3 +20,7 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
- Set a label for the filesystem:
|
||||
|
||||
`sudo mkfs.btrfs {{[-L|--label]}} "{{label}}" {{/dev/sdX /dev/sdY ...}}`
|
||||
|
||||
- Overwrite existing filesystem if one is detected:
|
||||
|
||||
`sudo mkfs.btrfs {{[-f|--force]}} {{/dev/sdX}}`
|
||||
|
||||
@@ -5,7 +5,7 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# mise
|
||||
|
||||
> Manage versions of different packages.
|
||||
> Manage language runtimes like Node.js, Python, Ruby, Go, Java, etc and various tools.
|
||||
> More information: <https://mise.jdx.dev>.
|
||||
|
||||
- List all available plugins:
|
||||
@@ -35,3 +35,7 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
- Set environment variable in configuration:
|
||||
|
||||
`mise set {{variable}}={{value}}`
|
||||
|
||||
- Pass plugin options:
|
||||
|
||||
`mise use {{name}}\[{{option1}}={{option1_value}},{{option2}}={{option2_value}}\]@{{version}}`
|
||||
|
||||
20
tldr/xh
20
tldr/xh
@@ -10,26 +10,30 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
> See also: `http`, `curl`.
|
||||
> More information: <https://github.com/ducaale/xh>.
|
||||
|
||||
- Send a GET request:
|
||||
- Send a GET request (shows response headers and content):
|
||||
|
||||
`xh {{httpbin.org/get}}`
|
||||
`xh {{https://postman-echo.com/get}}`
|
||||
|
||||
- Send a POST request with a JSON body (key-value pairs are added to a top-level JSON object - e.g. `{"name": "john", "age": 25}`):
|
||||
|
||||
`xh post {{httpbin.org/post}} {{name=john}} {{age:=25}}`
|
||||
`xh post {{https://postman-echo.com/post}} {{name=john}} {{age=25}}`
|
||||
|
||||
- Send a GET request with query parameters (e.g. `first_param=5&second_param=true`):
|
||||
- Send a GET request with query parameters (e.g. `https://postman-echo.com/response-headers?foo1=bar1&foo2=bar2`):
|
||||
|
||||
`xh get {{httpbin.org/get}} {{first_param==5}} {{second_param==true}}`
|
||||
`xh get {{https://postman-echo.com/response-headers}} {{foo1==bar1}} {{foo2==bar2}}`
|
||||
|
||||
- Send a GET request with a custom header:
|
||||
|
||||
`xh get {{httpbin.org/get}} {{header-name:header-value}}`
|
||||
`xh get {{https://postman-echo.com}} {{header-name:header-value}}`
|
||||
|
||||
- Make a GET request and save the response body to a file:
|
||||
|
||||
`xh --download {{httpbin.org/json}} --output {{path/to/file}}`
|
||||
`xh {{[-d|--download]}} {{https://example.com}} {{[-o|--output]}} {{path/to/file}}`
|
||||
|
||||
- Construct a request but do not send it (similar to a dry-run):
|
||||
|
||||
`xh --offline {{get|delete|...}} {{https://example.com}}`
|
||||
|
||||
- Show equivalent `curl` command (this will not send any request):
|
||||
|
||||
`xh --{{curl|curl-long}} {{--follow --verbose get http://example.com user-agent:curl}}`
|
||||
`xh --{{curl|curl-long}} {{--follow --verbose get https://example.com user-agent:curl}}`
|
||||
|
||||
Reference in New Issue
Block a user