mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-02-05 22:44:37 +00:00
34 lines
695 B
Plaintext
34 lines
695 B
Plaintext
---
|
|
syntax: markdown
|
|
tags: [tldr, common]
|
|
source: https://github.com/tldr-pages/tldr.git
|
|
---
|
|
# Greater than
|
|
|
|
> Redirect output.
|
|
> 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 `stderr` to `/dev/null` to keep the terminal output clean:
|
|
|
|
`{{command}} 2> /dev/null`
|
|
|
|
- Clear the file contents or create a new empty file:
|
|
|
|
`> {{path/to/file}}`
|
|
|
|
- Redirect `stderr` to `stdout` for piping them together:
|
|
|
|
`{{command1}} 2>&1 | {{command2}}`
|