> For the complete documentation index, see [llms.txt](https://hezhiqiang.gitbook.io/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hezhiqiang.gitbook.io/linux/ming-ling/ed.md).

# ed

单行纯文本编辑器

## 补充说明

**ed命令** 是单行纯文本编辑器，它有命令模式（command mode）和输入模式（input mode）两种工作模式。ed命令支持多个内置命令，常见内置命令如下：

### 语法

```
ed(选项)(参数)
```

### 选项

```
A # 切换到输入模式，在文件的最后一行之后输入新的内容；
C # 切换到输入模式，用输入的内容替换掉最后一行的内容；
i # 切换到输入模式，在当前行之前加入一个新的空行来输入内容；
d # 用于删除最后一行文本内容；
n # 用于显示最后一行的行号和内容；
w # <文件名>：一给定的文件名保存当前正在编辑的文件；
q # 退出ed编辑器。
```

```
-G或——traditional：提供兼容的功能；
-p<字符串>：指定ed在command mode的提示字符；
-s，-，--quiet或——silent：不执行开启文件时的检查功能；
--help：显示帮助；
--version：显示版本信息。
```

### 参数

文件：待编辑的文件。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://hezhiqiang.gitbook.io/linux/ming-ling/ed.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
