wiki/运维/操作系统/Linux/笔记/17.IO重定向.md
2025-01-02 10:46:09 +08:00

28 lines
711 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 1、标准输入和输出
**Linux给程序提供三种I/O设备**
- 标准输入STDIN -0 默认接收来自终端窗口的输入
- 标准输出STDOUT -1 默认输出到终端窗口
- 标准错误STDERR -2 默认输出到终端串口
STDOUT和STDERR都可以被重定向到指定文件而非默认当前的终端
```shell
1>或> 把STDOUT 重定向到文件
2> 把STDERR 重定向到文件
&> 把标准输出和标准错误都输出到文件
```
## 2、多行重定向
不一定要EOF任何字符都行
```shell
cat > 1.txt <<EOF
> 1231231
> asasssf
> EOF
```
## 3、管道
简介把命令1 的输出最为 命令2的输入...
命令1 | 命令2 | 命令3