# 管道及I/O重定向

## 输出重定向

![](https://github.com/clay-wangzhi/wiki/tree/ad8da33d2cec6c9b4eefadb893708ef16537ed64/Linux/基础/images/biaozhun.png) 输出重定向（覆盖）

```
date > a.txt
```

输出重定向（追加）

```
date 1>> a.txt
```

错误输出重定向

```
ls /home/ /aa >> a.txt 2>b.txt
```

正确和错误都输入到相同位置

```
ls /home/ /aa &> a.txt 
ls /home/ /aa > a.txt 2>&1
```

重定向到空设备/dev/null

```
ls /home/ /aa &> /dev/null
```

## 输入重定向

```
grep 'root' < /etc/passwd
```

```
mysql -uroot -p123 < aa.sql
```

## 总和应用

```
cat > a.txt <<EOF
> 11
> 22
> EOF
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.clay-wangzhi.com/linux/guan-dao-ji-io-zhong-ding-xiang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
