mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-01-26 11:33:59 +00:00
Update cheatsheets
This commit is contained in:
10
tldr/awk
10
tldr/awk
@@ -32,10 +32,12 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
|
||||
`awk '{if ($1 == "foo") print "Exact match foo"; else if ($1 ~ "bar") print "Partial match bar"; else print "Baz"}' {{path/to/file}}`
|
||||
|
||||
- Print all lines where the 10th column value equals the specified value:
|
||||
|
||||
`awk '($10 == {{value}})'`
|
||||
|
||||
- Print all the lines which the 10th column value is between a min and a max:
|
||||
|
||||
`awk '($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):
|
||||
|
||||
`awk 'BEGIN {FS=":";printf "%-20s %6s %25s
|
||||
", "Name", "UID", "Shell"} $4 >= 1000 {printf "%-20s %6d %25s
|
||||
", $1, $4, $7}' /etc/passwd`
|
||||
|
||||
36
tldr/http
36
tldr/http
@@ -5,33 +5,37 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# http
|
||||
|
||||
> HTTPie: HTTP client, aims to be easier to use than cURL.
|
||||
> More information: <https://httpie.org>.
|
||||
> HTTPie: an HTTP client designed for testing, debugging, and generally interacting with APIs & HTTP servers.
|
||||
> More information: <https://httpie.io/docs/cli/usage>.
|
||||
|
||||
- Download a URL to a file:
|
||||
- Make a simple GET request (shows response header and content):
|
||||
|
||||
`http --download {{example.org}}`
|
||||
`http {{https://example.org}}`
|
||||
|
||||
- Send form-encoded data:
|
||||
- Print specific output content (`H`: request headers, `B`: request body, `h`: response headers, `b`: response body, `m`: response metadata):
|
||||
|
||||
`http --form {{example.org}} {{name='bob'}} {{profile_picture@'bob.png'}}`
|
||||
`http --print {{H|B|h|b|m|Hh|Hhb|...}} {{https://example.com}}`
|
||||
|
||||
- Send JSON object:
|
||||
- Specify the HTTP method when sending a request:
|
||||
|
||||
`http {{example.org}} {{name='bob'}}`
|
||||
`http {{GET|POST|HEAD|PUT|PATCH|DELETE|...}} {{https://example.com}}`
|
||||
|
||||
- Specify an HTTP method:
|
||||
- Follow any `3xx` redirects and specify additional headers in a request:
|
||||
|
||||
`http {{HEAD}} {{example.org}}`
|
||||
`http {{--follow|-F}} {{https://example.com}} {{'User-Agent: Mozilla/5.0' 'Accept-Encoding: gzip'}}`
|
||||
|
||||
- Include an extra header:
|
||||
- Authenticate to a server using different authentication methods:
|
||||
|
||||
`http {{example.org}} {{X-MyHeader:123}}`
|
||||
`http --auth {{username:password|token}} --auth-type {{basic|digest|bearer}} {{GET|POST|...}} {{https://example.com/auth}}`
|
||||
|
||||
- Pass a username and password for server authentication:
|
||||
- Construct a request but do not send it (similar to a dry-run):
|
||||
|
||||
`http --auth {{username:password}} {{example.org}}`
|
||||
`http --offline {{GET|DELETE|...}} {{https://example.com}}`
|
||||
|
||||
- Specify raw request body via `stdin`:
|
||||
- Use named sessions for persistent custom headers, auth credentials and cookies:
|
||||
|
||||
`cat {{data.txt}} | http PUT {{example.org}}`
|
||||
`http --session {{session_name|path/to/session.json}} {{--auth username:password https://example.com/auth API-KEY:xxx}}`
|
||||
|
||||
- Upload a file to a form (the example below assumes form field is `<input type="file" name="cv" />`):
|
||||
|
||||
`http --form {{POST}} {{https://example.com/upload}} {{cv@path/to/file}}`
|
||||
|
||||
37
tldr/httpie
37
tldr/httpie
@@ -5,37 +5,18 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# httpie
|
||||
|
||||
> A user friendly HTTP tool.
|
||||
> More information: <https://github.com/httpie/httpie>.
|
||||
> Management interface for HTTPie.
|
||||
> See also: `http`, the tool itself.
|
||||
> More information: <https://httpie.io/docs/cli/plugin-manager>.
|
||||
|
||||
- Send a GET request (default method with no request data):
|
||||
- Check updates for `http`:
|
||||
|
||||
`http {{https://example.com}}`
|
||||
`httpie cli check-updates`
|
||||
|
||||
- Send a POST request (default method with request data):
|
||||
- List installed `http` plugins:
|
||||
|
||||
`http {{https://example.com}} {{hello=World}}`
|
||||
`httpie cli plugins list`
|
||||
|
||||
- Send a POST request with redirected input:
|
||||
- Install/upgrade/uninstall plugins:
|
||||
|
||||
`http {{https://example.com}} < {{file.json}}`
|
||||
|
||||
- Send a PUT request with a given JSON body:
|
||||
|
||||
`http PUT {{https://example.com/todos/7}} {{hello=world}}`
|
||||
|
||||
- Send a DELETE request with a given request header:
|
||||
|
||||
`http DELETE {{https://example.com/todos/7}} {{API-Key:foo}}`
|
||||
|
||||
- Show the whole HTTP exchange (both request and response):
|
||||
|
||||
`http -v {{https://example.com}}`
|
||||
|
||||
- Download a file:
|
||||
|
||||
`http --download {{https://example.com}}`
|
||||
|
||||
- Follow redirects and show intermediary requests and responses:
|
||||
|
||||
`http --follow --all {{https://example.com}}`
|
||||
`httpie cli plugins {{install|upgrade|uninstall}} {{plugin_name}}`
|
||||
|
||||
Reference in New Issue
Block a user