mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-03-28 21:16:20 +01:00
<, >, |, $: add page (#13846)
Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com> Co-authored-by: Wiktor Perskawiec <git@spageektti.cc> Co-authored-by: Lena <126529524+acuteenvy@users.noreply.github.com>
This commit is contained in:
parent
96fe1b83b9
commit
ac3c978a0f
4 changed files with 65 additions and 0 deletions
24
pages/common/$.md
Normal file
24
pages/common/$.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Dollar sign
|
||||
|
||||
> Expand a bash variable.
|
||||
> More information: <https://gnu.org/software/bash/manual/bash.html#Shell-Variables>.
|
||||
|
||||
- Print a variable:
|
||||
|
||||
`echo ${{VARIABLE}}`
|
||||
|
||||
- Print the exit status of the previous command:
|
||||
|
||||
`echo $?`
|
||||
|
||||
- Print a random number between 0 and 32767:
|
||||
|
||||
`echo $RANDOM`
|
||||
|
||||
- Print one of the prompt strings:
|
||||
|
||||
`echo ${{PS1|PS2|PS3|PS4}}`
|
||||
|
||||
- Expand with the output of `command` and run it. Same as enclosing `command` in backtics:
|
||||
|
||||
`$({{command}})`
|
20
pages/common/greater-than.md
Normal file
20
pages/common/greater-than.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Greater than
|
||||
|
||||
> Redirect output to a file.
|
||||
> More information: <https://gnu.org/software/bash/manual/bash.html#Redirecting-Output>.
|
||||
|
||||
- Redirect `stdout` to a file:
|
||||
|
||||
`{{command}} > {{path/to/file}}`
|
||||
|
||||
- Append to a file:
|
||||
|
||||
`{{command}} >> {{path/to/file}}`
|
||||
|
||||
- Redirect both `stdout` and `stderr` to a file:
|
||||
|
||||
`{{command}} &> {{path/to/file}}`
|
||||
|
||||
- Redirect both `stdout` and `stderr` to `/dev/null` to keep the terminal output clean:
|
||||
|
||||
`{{command}} &> /dev/null`
|
9
pages/common/less-than.md
Normal file
9
pages/common/less-than.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Less than
|
||||
|
||||
> Redirect a file to `stdin`.
|
||||
> Achieves the same effect as `cat file.txt |`.
|
||||
> More information: <https://gnu.org/software/bash/manual/bash.html#Redirecting-Input>.
|
||||
|
||||
- Redirect a file to `stdin`:
|
||||
|
||||
`{{command}} < {{path/to/file.txt}}`
|
12
pages/common/vertical-bar.md
Normal file
12
pages/common/vertical-bar.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Vertical bar
|
||||
|
||||
> Pipe data between programs.
|
||||
> More information: <https://gnu.org/software/bash/manual/bash.html#Pipelines>.
|
||||
|
||||
- Pipe `stdout` to `stdin`:
|
||||
|
||||
`{{command}} | {{command}}`
|
||||
|
||||
- Pipe both `stdout` and `stderr` to `stdin`:
|
||||
|
||||
`{{command}} |& {{command}}`
|
Loading…
Add table
Reference in a new issue